[英]Discord.js V13 Welcome Message
I'm still fairly new to creating bots, so this welcome message worked back in discord.js v12 but no longer works for me in v13.我对创建机器人还是很陌生,所以这个欢迎信息在 discord.js v12 中起作用,但在 v13 中不再适用于我。 I am trying to send a message in a specific channel when someone joins the server, but I checked, and
.send
does not exist on GuildChannel.当有人加入服务器时,我试图在特定频道中发送消息,但我检查过,
.send
上不存在 .send。 I checked to documentation but they all talk about sending message embeds, but I'm just trying to send a plain message to TextChannel
Here is the code.我查看了文档,但他们都在谈论发送消息嵌入,但我只是想向
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}>!**`);
});
I can provide more information if needed.如果需要,我可以提供更多信息。 Any help will be appreciated.
任何帮助将不胜感激。
You need GUILD_MEMBERS
intent in both the code and discord developer portal.在代码和不和谐开发人员门户中都需要
GUILD_MEMBERS
意图。
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS //also enable in discord developer portal
]
})
To answer the other part of your other question, the .send
exists on TextChannel
s.要回答其他问题的另一部分,
.send
存在于TextChannel
。 TextChannel
extends BaseGuildTextChannel
which extends GuildChannel
. TextChannel
扩展了BaseGuildTextChannel
,它扩展了GuildChannel
。 It's like this because it can be a VoiceChannel
!之所以这样,是因为它可以是
VoiceChannel
!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.