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

时间:2018-11-07 14:55:50

标签: javascript node.js discord.js

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

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

1 个答案:

答案 0 :(得分:1)

问题是当您找到频道时,client.channels.get 不是方法。在这种情况下由于我不知道的原因而无法工作

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