【发布时间】:2021-12-24 06:59:35
【问题描述】:
我对创建机器人还很陌生,所以这条欢迎消息在 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}>!**`);
});
如果需要,我可以提供更多信息。任何帮助将不胜感激。
【问题讨论】:
-
你需要
GUILD_MEMBERS在代码和不和谐开发者门户中的意图。.send存在于TextChannels 上,GuildChannel只是它的扩展,.send不存在,因为它可能是VoiceChannel! (实际上TextChannel扩展了BaseGuildTextChannel扩展了GuildChannel) -
@MrMythical 您想留下您的建议作为评论吗?因为它对我有用,我想感谢你,但这不是答案。
标签: javascript node.js discord discord.js