const youssef = require('./src/configs/profile.js') client.on('interactionCreate', async message => { if(message.isCommand() && message.commandName === 'title') { let title1 = message.options.getString('title_name') if (!title1) { title1 = "" } if (title1.length > 21) { return message.lineReplyNoMention(`only 20 letter please`) } youssef.findOne({ userId: message.user.id }, async (err, data) => { if (data) { data.title = title1 data.save() } else { new youssef({ userId: message.user.id, title: title1 }).save() } message.reply('✅') }) } } ) client.on('interactionCreate', async message => { if(message.isCommand() && message.commandName === 'back_profile') { let backprofile1 = message.options.getString('profile_url') if (!backprofile1) { backprofile = "https://cdn.discordapp.com/attachments/911397697116856380/927582096912965662/1641223087183.png" } youssef.findOne({ userId: message.user.id }, async (err, data) => { if (data) { data.backprofile = backprofile1 data.save() } else { new youssef({ userId: message.user.id, backprofile: backprofile1 }).save() } message.reply('✅') }) } } ) const { registerFont } = require('canvas') const { resolveImage, Canvas } = require('canvas-constructor/cairo') registerFont('./configurations/fonts/JosefinSans-Medium.ttf', { family: 'angry' }) registerFont('./configurations/fonts/Tajawal-Medium.ttf', { family: 'angry' }) registerFont('./configurations/fonts/arial.ttf', { family: 'angry' }) 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) youssef.findOne({ userId: user.id }, async (err, data) => { if (!data) { new youssef({ userId: user.id, title: "", level: "0", xp: "0", backprofile: "" }).save() } }) youssef.findOne({ userId: user.id }, async (err, data) => { userimg = user.avatarURL({ format: 'png' }), avt = await resolveImage(userimg) let image = await resolveImage(backprofile) async function card() { let ctx = new Canvas(1024, 1024) .setColor('black') .setTextFont('55px angry') .printImage(image, 0, 0, 1024, 1024) .printCircle(220, 208, 152) .printCircularImage(avt, 220, 208, 144) .setTextFont('55px angry') .printText(user.username, 450, 250, 400, 224) .setTextFont('55px angry') .printText('Level', 55, 450) .setTextFont('55px angry') .printText(`${data.level}`, 55, 510) .setTextFont('55px angry') .printText('credits', 55, 600) .setTextFont('55px angry') .printText(`${dmd}`, 55, 660) .setTextFont('55px angry') .printText('Rep', 55, 750) .setTextFont('55px angry') .printText(`+${rp}`, 55, 810) .printText('Total xp', 55, 900,) .setTextFont('55px angry') .printText(`${data.xp}`, 65, 960) .setTextFont('55px angry') .printText(`${data.title || " "}`, 400, 570, 1000) .toBuffer() return ctx } await message.deferReply() message.editReply({ files: [{ attachment: await card(), name: 'profile.png' }] }) }) } } )