简体   繁体   中英

Edit embed message to simple text discord.js

I would like to edit an embed message to a simple text message using discord.js and node.js. I already tried this but it don't work:

const sentMessage = await message.channel.send({
  embed: { author: {name: 'Getting statistics for ' + message.author.username, icon_url: 'https://i.imgur.com/OWvklnj.gif'}}
})

[...]

sentMessage.edit("no statistics")

Using message.edit() alone won't work as it's only edits the content of the message. You can use the suppressEmbeds() method to remove the embed and then edit the content. The following should work:

try {
  const sentMessage = await message.channel.send({
    embed: {
      author: {
        name: 'Getting statistics for ' + message.author.username,
        icon_url: 'https://i.imgur.com/OWvklnj.gif',
      },
    },
  });

  await sentMessage.suppressEmbeds();
  await sentMessage.edit('no statistics');
} catch (error) {
  console.log(error);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM