我做了一个不和聊天机器人来编辑人们的个人资料,但结果是这样的。
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"
}
看起来您正在尝试使用普通文本命令而不是斜杠命令,因此您需要使用message.author.displayAvatarURL
而不是interaction.user.displayAvatarURL
!
const background = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'png' }));