我制作了一个不和谐的机器人,每当新成员加入时都会发出欢迎消息。这工作了几个月,直到最近才停止。似乎未调用“ guildMemberAdd”事件。我什么都没说这个事件的名字改变了。这是我的欢迎消息代码:
bot.on('guildMemberAdd', async member => {
const channel = member.guild.channels.cache.get('711481027704520735');
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage('./image.png');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
// Slightly smaller text placed above the member's display name
ctx.font = '28px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText('Welcome to The Vibe Zone,', canvas.width / 2.5, canvas.height / 3.5);
// Add an exclamation point here and below
ctx.fillStyle = '#ffffff';
ctx.font = '48px sans-serif';
ctx.fillText(`${member.displayName}!`, canvas.width / 2.5, 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: 'png' }));
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png');
channel.send(attachment);
});
答案 0 :(得分:0)
开发人员控制台中有一个开关,需要对不和谐进行切换。它称为“ PRESENCE INTENT”和“ SERVER MEMBERS INTENT”。