Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove a field from an embed by editing it?

So let's say I create an embed and sent it to a channel. Here's the embed:

const embed = new Discord.RichEmbed()
        .setColor(color)
        .setTitle(`${message.author.tag} wants to play.`)
        .setAuthor(message.author.tag, message.author.displayAvatarURL)
        .setDescription(game)
        .setThumbnail(icon)
        .addField(`\u200b\n**React with ${emoji} to join.**`, "Remove your reaction to leave.");

Once it's sent, I want to edit that embed's title and description and delete the field I added at the end.

Here's the new embed I'm trying to create:

const embed = new Discord.RichEmbed(reaction.message.embeds[0])
            .setTitle("This game has ended.")
            .setDescription("You can no longer join.");

This changes the title and description but I'm unsure on how to remove the field that I added too.

like image 879
Luke Chambers Avatar asked Dec 30 '25 01:12

Luke Chambers


1 Answers

I know this is 6 months old, but in case anyone else stumbles here like I did you should not set embed.fields to null. This prevents new fields from being added later using the addField method. Instead set it to an empty array.

embed.fields = [];

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!