I made a discord bot that edit peoples profiles, but it came out like this.
UnhandledPromiseRejectionWarning: ReferenceError: interaction is not defined
I'm new to programming
const Discord = require("discord.js")
const Canvas = require("canvas");
module.exports.run = async (bot, message, args)=> {
const canvas = Canvas.createCanvas(256, 256);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage(interaction.user.displayAvatarURL({ format: 'png' }));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
const avatar = await Canvas.loadImage('./bars.png');
ctx.drawImage(avatar, 25, 0, 200, canvas.height )
const attachment = new MessageAttachment(canvas.toBuffer(), 'jailxd.png');
message.channel.send(attachment);
}
exports.conf = {
enabled: true,
guildOnly: true,
aliase:["catch"]
}
exports.help = {
name:"jail",
description:"Empty",
usage:"jail",
category:"fun"
}
Looks like you are trying to make common text command and not slash command, so instead of interaction.user.displayAvatarURL you need to use message.author.displayAvatarURL!
const background = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'png' }));