Added banner in api
This commit is contained in:
1 parent
c348212aa9
commit
b774ae1192
7 files changed
+1069
-10
No files matched your search
Generated
+995
File diff suppressed because it is too large.
Load diff
+2
-1
@@ -5,7 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node index.js",
|
"start": "ode index.js",
|
||||||
"css": "postcss website/public/css/tailwind.css -o website/public/css/style.css"
|
"css": "postcss website/public/css/tailwind.css -o website/public/css/style.css"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autoprefixer": "^10.4.8",
|
"autoprefixer": "^10.4.8",
|
||||||
"body-parser": "^1.20.0",
|
"body-parser": "^1.20.0",
|
||||||
|
"canvas": "^2.9.3",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"cookie-session": "^2.0.0",
|
"cookie-session": "^2.0.0",
|
||||||
"discord.js": "^14.1.1",
|
"discord.js": "^14.1.1",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
@@ -10,7 +10,7 @@ router.get('/', function (req, res) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
router.get('/search/:id', function (req, res) {
|
router.get('/search/:id', function (req, res) {
|
||||||
bots.find({ $or: [{ id: { $regex: req.params.id } }, { name: { $regex: req.params.id } }] },async function (err, bot) {
|
bots.find({ $or: [{ id: { $regex: req.params.id } }, { name: { $regex: req.params.id } }] }, async function (err, bot) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
if (!bot) {
|
if (!bot) {
|
||||||
return
|
return
|
||||||
@@ -36,6 +36,69 @@ router.get('/search/:id', function (req, res) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
const applyText = (canvas, text) => {
|
||||||
|
const context = canvas.getContext('2d');
|
||||||
|
let fontSize = 70;
|
||||||
|
|
||||||
|
do {
|
||||||
|
context.font = `30px sans-serif`;
|
||||||
|
} while (context.measureText(text).width > canvas.width - 300);
|
||||||
|
|
||||||
|
return context.font;
|
||||||
|
};
|
||||||
|
const { createCanvas, loadImage, Image } = require('canvas')
|
||||||
|
const { readFile } = require('fs/promises');
|
||||||
|
|
||||||
|
router.get('/server/:id', function (req, res) {
|
||||||
|
// Get one server and draw it on the canvas
|
||||||
|
servers.findOne({ id: req.params.id }, async function (err, server) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (!server) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
const serverr = await global.bsl.guilds.cache.get(req.params.id)
|
||||||
|
if(!serverr)return
|
||||||
|
const serverName = server.name
|
||||||
|
const serverDescription = server.description
|
||||||
|
const serverMembers = serverr.memberCount
|
||||||
|
// Load the image
|
||||||
|
const avatar = await loadImage(`https://cdn.discordapp.com/icons/${serverr.id}/${serverr.icon}.jpg`)
|
||||||
|
// Draw the image
|
||||||
|
const canvas = createCanvas(700, 250);
|
||||||
|
const context = canvas.getContext('2d');
|
||||||
|
|
||||||
|
const background = await readFile('./website/public/img/wallpaper.jpg');
|
||||||
|
const backgroundImage = new Image();
|
||||||
|
backgroundImage.src = background;
|
||||||
|
context.drawImage(backgroundImage, 0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
context.strokeStyle = '#0099ff';
|
||||||
|
context.strokeRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
context.font = '15px sans-serif';
|
||||||
|
context.fillStyle = '#fff';
|
||||||
|
context.fillText('©️ BotsCord.xyz', canvas.width / 1.2, canvas.height / 1.05);
|
||||||
|
context.font = '30px sans-serif';
|
||||||
|
|
||||||
|
context.fillStyle = '#ffffff';
|
||||||
|
context.fillText(`BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB`, canvas.width / 2.7, canvas.height / 1.8);
|
||||||
|
context.font = '18px sans-serif';
|
||||||
|
|
||||||
|
context.fillText(`🙍♂️ ${serverMembers}`, canvas.width / 2.7, canvas.height / 1.1);
|
||||||
|
context.fillText(`❤️ ${server.votes}`, canvas.width / 2.1, canvas.height / 1.1);
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
context.arc(125, 125, 100, 0, Math.PI * 2, true);
|
||||||
|
context.closePath();
|
||||||
|
context.clip();
|
||||||
|
context.drawImage(avatar, 25, 25, 200, 200);
|
||||||
|
res.setHeader('Content-Type', 'image/png');
|
||||||
|
canvas.pngStream().pipe(res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
router.use(function (req, res, next) {
|
router.use(function (req, res, next) {
|
||||||
if (!req.headers.authorization) {
|
if (!req.headers.authorization) {
|
||||||
return res.status(403).json({ error: 'No credentials sent!' });
|
return res.status(403).json({ error: 'No credentials sent!' });
|
||||||
@@ -145,4 +208,5 @@ router.get('/bots/check/:id', function (req, res) {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
@@ -43,7 +43,6 @@ router.post('/add', async function (req, res) {
|
|||||||
req.session.error = "Server already exists";
|
req.session.error = "Server already exists";
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
}
|
}
|
||||||
//check if member has admin permissions
|
|
||||||
if (!checkServer.members.cache.get(req.user.id).permissions.has("ADMINISTRATOR")) {
|
if (!checkServer.members.cache.get(req.user.id).permissions.has("ADMINISTRATOR")) {
|
||||||
req.session.error = "You do not have admin permissions";
|
req.session.error = "You do not have admin permissions";
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
@@ -55,8 +54,6 @@ router.post('/add', async function (req, res) {
|
|||||||
req.session.error = "Could not create invite";
|
req.session.error = "Could not create invite";
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
channel.createInvite({
|
channel.createInvite({
|
||||||
maxAge: 0,
|
maxAge: 0,
|
||||||
maxUses: 0,
|
maxUses: 0,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<% if(typeof server !="undefined" ) { %>
|
<% if(typeof server !="undefined" ) { %>
|
||||||
<meta property="og:title" content="BotsCord.xyz" />
|
<meta property="og:title" content="BotsCord.xyz" />
|
||||||
<meta property="og:url" content="http://botscord.xyz/server/<%=server.id %>" />
|
<meta property="og:url" content="http://botscord.xyz/server/<%=server.id %>" />
|
||||||
<meta property="og:image" content="<%= server.icon %>" />
|
<meta property="og:image" content="https://cdn.discordapp.com/avatars/<%=server.id %>/<%=global.bsl.guilds.cache.get(server.id).icon %>.png" />
|
||||||
<meta property="og:description" content="<%= server.description %>
|
<meta property="og:description" content="<%= server.description %>
|
||||||
|
|
||||||
🟢 <%= global.bsl.guilds.cache.get(server.id).members.cache.filter(a => a.presence?.status).size %> onlineᅠᅠᅠᅠ⚫ <%= global.bsl.guilds.cache.get(server.id).memberCount %> members">
|
🟢 <%= global.bsl.guilds.cache.get(server.id).members.cache.filter(a => a.presence?.status).size %> onlineᅠᅠᅠᅠ⚫ <%= global.bsl.guilds.cache.get(server.id).memberCount %> members">
|
||||||
@@ -88,9 +88,11 @@
|
|||||||
<li class="fa fa-server mr-1"></li>Edit server
|
<li class="fa fa-server mr-1"></li>Edit server
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="py-1" role="none">
|
||||||
|
<a target=”_blank” href="https://docs.botscord.xyz" class="text-gray-700 block px-4 py-2 text-sm" role="menuitem" tabindex="-1" id="menu-item-2"><i class="fa fa-solid fa-book"></i>Docs</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- dropdown menu with tailwindcss -->
|
|
||||||
</div>
|
</div>
|
||||||
<% if (typeof user=="undefined" ) { %>
|
<% if (typeof user=="undefined" ) { %>
|
||||||
<a href="/auth" class="inline-block text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-blue-color hover:bg-white mt-4 lg:mt-0 w-fit h-fit">Login</a>
|
<a href="/auth" class="inline-block text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-blue-color hover:bg-white mt-4 lg:mt-0 w-fit h-fit">Login</a>
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="simple-search" class="bg-primary-color border border-gray-300 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-primary-color dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Search" required>
|
<input type="text" id="simple-search" class="bg-primary-color border border-gray-300 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-primary-color dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Search" required>
|
||||||
|
|
||||||
<div id="search-results" class="hidden bg-primary-color border border-gray-300 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full pl-10 p-2.5 dark:bg-primary-color dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"></div>
|
<div id="search-results" class="hidden bg-primary-color border border-gray-300 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full pl-10 p-2.5 dark:bg-primary-color dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"></div>
|
||||||
</div>
|
</div>
|
||||||
</form><br>
|
</form><br>
|
||||||
@@ -35,14 +34,15 @@
|
|||||||
type: 'GET',
|
type: 'GET',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var html = '';
|
var html = '';
|
||||||
|
if(!data.serverArray.length) html = '<div class="text-center">No results found</div>';
|
||||||
for (var i = 0; i < data.serverArray.length; i++) {
|
for (var i = 0; i < data.serverArray.length; i++) {
|
||||||
if (i == 5) {
|
if (i == 5) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (data.serverArray[i].type == 'server') {
|
if (data.serverArray[i].type == 'server') {
|
||||||
html += '<a href="/server/' + data.serverArray[i].id + '" class="flex items-center p-2 border-b border-gray-300 hover:bg-primary-color hover:text-white"><img title="botscord.site" class="mr-2" width="48" onError="this.src = ' + "'/img/logo.webp'" + '" style="border-radius: 8px;" src="' + data.serverArray[i].avatar + '" />' + data.serverArray[i].name + '</a>';
|
html += '<a href="/server/' + data.serverArray[i].id + '" class="flex items-center p-2 border-b border-gray-300 hover:bg-primary-color hover:text-white"><img title="botscord.site" class="mr-2" width="48" onError="this.src = ' + "'/img/logo.webp'" + '" style="border-radius: 8px;" src="' + data.serverArray[i].avatar + '" />' + data.serverArray[i].name + ' | Server</a>';
|
||||||
} else {
|
} else {
|
||||||
html += '<a href="/bot/' + data.serverArray[i].id + '" class="flex items-center p-2 border-b border-gray-300 hover:bg-primary-color hover:text-white"><img title="botscord.site" class="mr-2" width="48" onError="this.src = ' + " '/img/logo.webp'" + '" style="border-radius: 8px;" src="' + data.serverArray[i].avatar + '" />' + data.serverArray[i].name + '</a>';
|
html += '<a href="/bot/' + data.serverArray[i].id + '" class="flex items-center p-2 border-b border-gray-300 hover:bg-primary-color hover:text-white"><img title="botscord.site" class="mr-2" width="48" onError="this.src = ' + " '/img/logo.webp'" + '" style="border-radius: 8px;" src="' + data.serverArray[i].avatar + '" />' + data.serverArray[i].name + ' | Bot </a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var searchr = document.getElementById('search-results');
|
var searchr = document.getElementById('search-results');
|
||||||
|
|||||||
Reference in new issue
Block a user