client.on('interactionCreate', async message => { if(message.isCommand() && message.commandName === 'profile') { let user = message.options.getUser('user') if (!user) user = message.user; if (user.bot) return message.reply('> Bots do not have a profile card') const dmd = await client.bal(user.id) const rp = await client.rbal(user.id) let data = await youssef.find({}) let raank = data.sort((a,b) => b.level-a.level).findIndex(m=> m.userId === user.id) + 1 youssef.findOne({ userId: user.id }, async (err, data) => { if (!data) { data = await new youssef({ userId: user.id, title: "", backprofile: "my image link i don't want you to see it ", level: "0", xp: "0", color: "" }) } youssef.findOne({ userId: user.id }, async (err, data) => { userimg = user.displayAvatarURL({ format: 'png' }), avt = await resolveImage(userimg) guildimg = message.guild.iconURL({ format: 'png' }), guildavt = await resolveImage(guildimg) let image = await resolveImage(`${data.backprofile}`) async function card() { let ctx = new Canvas(1024, 1024) .setColor(`${data.color || "WHITE"}`) .setTextFont('55px angry') .printImage(image, 0, 0, 1024, 1024) .printCircle(220, 208, 152) .printCircularImage(avt, 220, 208, 144) .printCircularImage(guildavt, 900, 120, 55) .setTextFont('55px angry') .printText(user.username, 450, 250, 400, 224) .setTextFont('55px angry') .printText('RANK', 35, 900) .setTextFont('55px angry') .printText(raank, 45, 960) .setTextFont('55px angry') .printText('LVL', 35, 450) .setTextFont('55px angry') .printText(`${data.level}`, 35, 510) .setTextFont('55px angry') .printText('CREDITS', 35, 600) .setTextFont('55px angry') .printText(`${dmd}`, 35, 660) .setTextFont('55px angry') .printText('REP', 35, 750) .setTextFont('55px angry') .printText(`+${rp}`, 35, 810) .printText('TOTAL XP', 400, 900, 1000) .setTextFont('55px angry') .printText(`${data.xp}`, 400, 960) .setTextFont('55px angry') .printText(`${data.title || " "}`, 400, 600, 1000) .toBuffer() return ctx } await message.deferReply() message.editReply({ files: [{ attachment: await card(), name: 'profile.png' }] }) }) }) } } )