[英]Discord bot, embeded welcome message not working
我正在编写一个 discord 机器人,但我遇到了一个问题,我对此很陌生,我正在努力学习。 我试图让这个欢迎信息发挥作用,但它不会,有什么想法吗?
const Discord = require('discord.js');
const client = new Discord.Client();
const token = "HIDDEN";
const rules = " Coming Soon ";
var prefix = "/";
client.on('ready', () => {
console.log("Azorf is online!");
});
client.on('guildMemberAdd', member => {
let embed = new Discord.MessageEmbed()
.setDescription(':tada: **' + member.user.username + '** joined ' + member.guild.name)
.setFooter('We are now ' + member.guild.memberCount)
member.guild.channels.get('822024147202080771').send(embed)
});
client.on('message', message => {
if (message.author.bot) return;
if (message.content.toLowerCase() === '/rules') {
const embed = new Discord.MessageEmbed()
embed.setColor('#bd0000');
embed.setTitle("Server Rules");
embed.addField("These are the rules of the server:", rules);
message.channel.send({embed});
}
});
client.login(token);
此问题是由于在Discord 开发人员门户中未启用成员意图时 guildMemberAdd 未触发,您还可以通过手动发出 guildMemberAdd 事件来解决您的事件。
if (message.content.toLowerCase() === '/join') {
client.emit('guildMemberJoin', message.member)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.