如何从嵌入消息 Discord Bot 中获取 ID

How to get ID from embeded message Discordbot

我有一个问题。我想知道是否有可能从 discord 机器人发送的嵌入消息中获取 ID。我可以获得 Discord 机器人发送的普通消息的 ID,但是当我发送嵌入时,我没有从中获得 ID。有谁知道我该如何解决这个问题?我已经尝试了很多东西,但我没有从我的 Discord 机器人发送的最后一个嵌入中得到任何 ID

提前致谢!

代码:

 module.exports = 
{
  name: "reactionrole",
  description: "Sets up a reaction role message!",
  category: "info",
  usage: "Test <>",
  async execute(message, args, cmd, _client, Discord) 
  {
    const channel = '719992310988931143';
    const channel_by_ID = _client.channels.cache.get(channel);
    console.log("Chanel ID: " + channel_by_ID) // --> Geef Chanel ID
    console.log("Laatste message ID (USER): " + channel_by_ID.lastMessageID) // --> Message ID
    const yellowTeamRole = message.guild.roles.cache.find(role => role.name === "Davmin");
    const yellowTeamEmoji = ``;
    global.globalvar;


    let test = new Discord.MessageEmbed()
      .setTitle("HOUSE RULES By connecting to this Discord server, you agree to the Holy Davino house rules.")
      .setColor("#ff2050")
      .setDescription("Choosing a team will allow you to interact with your teammates!\n\n"+ `${yellowTeamEmoji} for yellow team\n`)
      var bericht = await message.channel.send({embed: test}).then(embedMessage => {embedMessage.react(yellowTeamEmoji)});
      var testmessage = await message.channel.send("test")
     
    console.log("Test message: " + testmessage)
    // ID = bericht.id --> Not working
    console.log("Embed: " +  bericht)

    
        

    _client.on('messageReactionAdd', async(reaction, user, globalvar) => {

      console.log("React!")
      console.log("Global var (_Client.on): " + global.globalvar)
      console.log("Message ID (_Client.on): " + reaction.message.id)
      if(reaction.message.id == global.globalvar)
      {
        console.log("Wtf tot hier?");
        if(reaction.emoji.user === yellowTeamEmoji)
        {
          console("We zijn der ver!!!")
          reaction.message.guild.member(user).roles.add(yellowTeamRole);
        }
      }
      else 
      {
        console.log("Hij geraakt er niet")
      }
    });

  }
}

日志:

var bericht = await message.channel.send({embed: test}).then(embedMessage => {embedMessage.react(yellowTeamEmoji)});

bericht 变量上,您正在发送一条消息然后对其作出反应,但您没有指定它是什么 return。因此,embedMessage => embedMessage.react(yellowTeamEmoji)} returned undefined

如果您希望机器人返回消息 ID,您必须指定它。

var bericht = await message.channel.send({embed: test}).then(embedMessage =>{
  embedMessage.react(yellowTeamEmoji);
  return embedMessage.id;
});