[英]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.