我尝试了一段时间,但由于某种原因,我的Discord服务器欢迎消息不起作用。如果有人可以帮助,将不胜感激。 这是我的代码:
bot.on("guildMemberAdd", member => {
const welcomeChannel = member.guild.channels.cache.find(channel => channel.name === 'welcome')
var serverIcon = message.guild.iconURL();
const embed = new Discord.MessageEmbed()
.setTitle("Welcome!")
.setColor(3447003)
.setDescription(`Welcome <${member.user.username}> to ${guild.name}!`)
.addField(
{ name: ':D', value: 'Hope you enjoy your stay!'}
)
.setFooter("© Ninjabot 2020", bot.user.avatarURL)
.setThumbnail(serverIcon)
.setTimestamp()
welcomeChannel.send({embed});
})
答案 0 :(得分:0)
尝试更换
welcomeChannel.send({embed});
使用
welcomeChannel.send(${embed});
或
welcomeChannel.send(embed);
示例:
client.on('guildMemberAdd', member => {
member.roles.add(member.guild.roles.cache.find(i => i.name === 'Among The Server'))
const welcomeEmbed = new Discord.MessageEmbed()
welcomeEmbed.setColor('#5cf000')
welcomeEmbed.setTitle('**' + member.user.username + '** is now Among Us other **' + member.guild.memberCount + '** people')
welcomeEmbed.setImage('https://myurl')
member.guild.channels.cache.find(i => i.name === 'greetings').send(welcomeEmbed)
});