本文介紹了使用 discord.js 加入 discord 服務器時的歡迎消息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在使用 node.js 和 discord.js 制作一個不和諧機器人,我目前正在嘗試制作它,以便當用戶加入不和諧服務器時,會發送自定義歡迎消息.這是我的代碼:
I am making a discord bot using node.js and discord.js, and I am currently trying to make it so that when a user joins the discord server, a custom welcome message is sent. Here is my code:
bot.on("guildMemberAdd" ,(message, member) => {
message.channel.send("Welcome")
});
這是得到的錯誤:
message.channel.send("Welcome")
^
TypeError: Cannot read property 'send' of undefined
感謝您的幫助.
推薦答案
如果您閱讀了 documentation,沒有message
參數,只有member
.您必須先獲取公會頻道 ID.
If you read the documentation, there's is no message
parameter, only member
. You will have to get the guild's channel ID first.
試試這樣的:
bot.on('guildMemberAdd', member => {
member.guild.channels.get('channelID').send("Welcome");
});
這篇關于使用 discord.js 加入 discord 服務器時的歡迎消息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!