This is a Extra Command For The Leveling system by Hakiki:-(https://autocode.com/snippet/Hakiki/cachsnpt_kvn6MwajD45GvjegZY2Ne7ZUs4XQB76rynv5) it shows the levels in a png instead of A Embed (DO NOT FORGET TO REMOVE LINES FROM 85 TO 132 IN HAKIKIS LEVELING SYSTEM PROJECT)
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const jimp = require('jimp');
module.exports = async (event, context) => {
if (event.content.startsWith(`${process.env.PREFIX}level`)) {
let database = await lib.googlesheets.query['@0.3.0'].select({
range: `A:D`,
bounds: 'FULL_RANGE',
where: [
{
ID__icontains: `${context.params.event.author.id}`,
},
],
limit: {
count: 0,
offset: 0,
},
});
let initialLevel = 0;
let points = 1;
let level = 0;
if (database.rows.length !== 0) {
initialLevel = database.rows[0].fields['Level'];
points = parseInt(database.rows[0].fields['Points']) + parseInt(1);
level = Math.floor(points / 50);
}
let timeout = await lib.utils.kv['@0.1.16'].get({
key: `timeout`,
defaultValue: false,
});
let member = event.author.id;
if (event.mentions.length >= 1) {
member = event.mentions[0].id;
}
let user = await lib.discord.users['@0.1.4'].retrieve({
user_id: member,
});
let img = await jimp.read(
'https://media.discordapp.net/attachments/902792331995009045/950000302621347890/unknown.png'
);
let avatar_jimp = await jimp.read(user.avatar_url);
avatar_jimp.circle();
avatar_jimp.resize(125, 125);
img.composite(avatar_jimp, 47, 33);
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => {
img.print(
font,
355,
85,
{
text: `${level}`,
},
300,
-20
);
});
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => {
img.print(
font,
355,
125,
{
text: `${points}`,
},
300,
-10
);
});
await jimp.loadFont(jimp.FONT_SANS_32_WHITE).then((font) => {
img.print(
font,
225,
35,
{
text: `${context.params.event.author.username}`,
},
300,
-20
);
});
let buffer = await img.getBufferAsync(jimp.MIME_PNG);
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: event.channel_id,
content: ``,
filename: 'user_level.png',
file: buffer,
});
}
};