我對創建機器人還是很陌生,所以這個歡迎資訊在 discord.js v12 中有效,但在 v13 中不再適用于我。當有人加入服務器時,我試圖在特定頻道中發送訊息,但我檢查過,并且.send在 GuildChannel 上不存在。我查看了檔案,但他們都在談論發送訊息嵌入,但我只是想向TextChannel這里發送一條簡單的訊息,這是代碼。
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
client.on('guildMemberAdd', guildMember => {
guildMember.guild.channels.cache.get('474431129613762571').send(`**Welcome to the discord server, <@${guildMember.user.id}>!**`);
});
如果需要,我可以提供更多資訊。任何幫助將不勝感激。
uj5u.com熱心網友回復:
您需要GUILD_MEMBERS在代碼和不和諧開發人員門戶中使用意圖。
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS //also enable in discord developer portal
]
})
要回答其他問題的另一部分,.send存在于TextChannels 上。TextChannelextendsBaseGuildTextChannel延伸GuildChannel. 之所以這樣,是因為它可以是VoiceChannel!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/356425.html
標籤:javascript 节点.js 不和谐 不和谐.js
