[英]Discord.js V13 Welcome Message
我对创建机器人还是很陌生,所以这个欢迎信息在 discord.js v12 中起作用,但在 v13 中不再适用于我。 当有人加入服务器时,我试图在特定频道中发送消息,但我检查过, .send
上不存在 .send。 我查看了文档,但他们都在谈论发送消息嵌入,但我只是想向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
意图。
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS //also enable in discord developer portal
]
})
要回答其他问题的另一部分, .send
存在于TextChannel
。 TextChannel
扩展了BaseGuildTextChannel
,它扩展了GuildChannel
。 之所以这样,是因为它可以是VoiceChannel
!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.