Discord.js quick.db error. Help?

Ok, the following code is something I’m not sure about. In my setup.js file (a configuration command for my welcome command) there are no errors executing the command, and it is saving everything to the sqlite file correctly. However, on my guildMemberAdd there is a weird error. To try and avoid this, I put everything in an async function. I have moved everything about, added and removed everything. Nothing is working. All i need is an answer, im sorry if this question has been asked before, its hard looking for a solution to a db.fetch line of code. Here is the full section of my guildMemberAdd

client.on('guildMemberAdd', async message => { const channel = db.fetch(guild_${message.guild.id}_welChann`) || “welcome”;

userInfo();

async function userInfo(member, message, guild) {

if (!channel)
{
return;
}
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext(‘2d’);

const background = await Canvas.loadImage(’./wallpaper.jpg’);
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

ctx.strokeStyle = ‘#74037b’;
ctx.strokeRect(0, 0, canvas.width, canvas.height);

// resized the text above the users name
ctx.font = ‘26px Sans’;
ctx.fillStyle = ‘#ffffff’;
ctx.fillText(‘Welcome to the server,’, canvas.width / 3.2, canvas.height / 3.5);

// pass canvas width and resize so name will fit inside of the image.
const applyText = (canvas, text) => {
const ctx = canvas.getContext(‘2d’);

// base size for the font
let fontSize = 60;

do {
    // assign the font (Sans only one i tested)
    ctx.font = `${fontSize -= 8}px Sans`;
    // resize (dont change)
  } while (ctx.measureText(text).width > canvas.width - 300);

// return to nnormal canvas size (resize)
return ctx.font;

};

ctx.font = applyText(canvas, ${member.displayName}!);
ctx.fillStyle = ‘#ffffff’;
ctx.fillText(${member.displayName}!, canvas.width / 2.9, canvas.height / 1.8);

ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();

const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: ‘jpg’ }));
ctx.drawImage(avatar, 25, 25, 200, 200);

const attachment = new MessageAttachment(canvas.toBuffer(), ‘welcome-image.png’);

message.channel.send(userInfo(${member} just joined the server. Welcome!, attachment));
}
`

To replicate this, you would need to use Canvas, quick.db and const {MessageAttactchment) = require('discord.js'); and a picture called wallpaper.jpg.

Im not the most advanced in javascript, and the majority of this code is used from a tutorial online (because i started this bot maybe… 4 months ago? and knew basically nothing about image manipulation) If you need any more information or anything please ask me. ill also respond if i have tried the method you suggest. If you need any more code please let me know!

FULL Error : ntadb - Ghostbin

it’d be much easier if you could show us all the code in your editor (specifically line 139 in the index.js file)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.