問題描述
我有一個代碼,如果有人加入機器人會發出歡迎消息,但當用戶加入時,機器人不會發出歡迎消息.
I have a code where if someone joins the bot gives a welcome message but when a user joins, the bot does not give the welcome message.
代碼:
bot.on('guildMemberAdd', member => {
const channel = member.guild.channels.cache.find(channel => channel.name === "general")
if (!channel) return;
const joinembed = new Discord.MessageEmbed()
.setTitle(`A new member just arrived!`)
.setDescription(`Welcome ${member} we hope you enjoy your stay here!`)
.setColor("#FF0000")
channel.send(joinembed)
});
我的機器人擁有所有權限并且位于角色層次結構的最頂端,請幫助我不知道我做錯了什么.當用戶離開時也會出現此問題(它也不會給出歡迎消息)
My bot has all the permissions and is at the very top of the role hierarchy, please help I don't know what am I doing wrong. This problem also applies when the user leaves (It also does not give the welcome message)
推薦答案
Discord 前幾天做了一些改動.該機器人未發送歡迎消息,因為它從未收到 guildMemberAdd
事件.從現在開始,要獲得這些類型的事件,您必須在開發門戶中打開意圖.完成此操作后,您的代碼將重新開始工作.
Discord made some changes a few days ago. The bot is not sending the welcome message because it never gets the guildMemberAdd
event. From now on to get these types of events you will have to turn the intents on in the dev portal. After doing this your code will start working again.
這篇關于公會成員添加不起作用(discordjs)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!