我在编写代码时遇到麻烦,因为它在同一通道中发送多次,但是多次发送,大约是4-20次,我不知道发生了什么,我急需帮助。谢谢!
client.on("guildCreate", guild => {
let defaultChannel = "";
guild.channels.cache.forEach((channel) => {
if(channel.type == "text" && defaultChannel == "") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
defaultChannel.send('Thanks for adding me to your server!')
});