{ const Discord = require(-6ren">
gpt4 book ai didi

javascript - 无法在加入时发送嵌入消息

转载 作者:行者123 更新时间:2023-12-03 00:47:21 24 4
gpt4 key购买 nike

不知道为什么它不起作用,确切的代码在我的旧机器人上有效。代码:

client.on("guildMemberAdd", member => {
const Discord = require("discord.js");
const embed = new Discord.RichEmbed()
.setTitle("**Please be sure to read our rules carefully thanks**")
.setAuthor("Welcome to BACKUP")
.setColor(3447003)
.setDescription("Please enjoy your stay")
.setThumbnail(message.author.avatarURL)
client.channels.get('505107608391254030').send({embed});
})
}

最让我困惑的是,如果我用这段代码替换该代码,它就可以正常工作。

client.on('guildMemberAdd', member => {
member.guild.channels.get('505107608391254030').send("This works, but embed does not, fix it boi, line 102");
});

(在不起作用的代码上,我尝试了:client.channels.get、member.channels.get、member.guild.channels.get、client.guild.channels.get

最佳答案

问题是当您找到 channel 时,client.channels.get 不是一种方法。在这种情况下不起作用,原因是我不知道

您必须使用client.guilds.get(GUILD_ID).channels.get(CHANNEL_ID).send({embed});

关于javascript - 无法在加入时发送嵌入消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53191974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com