Search code examples
javascriptnode.jsdiscorddiscord.js

Discord.js change embed color without erasing all other content


Hello im curreently trying to fetch an Embed and then chaging its color

However this erases all other embed contents

await msg.channel.messages.fetch("msgID")
        .then(message => {
            const embedsend = new MessageEmbed()
                .setColor('#7bf542')
            message.edit({ embeds: [embedsend] })
        })
        .catch(console.error);

This is how I fetch the message and edit the embed what am I doing wrong ?

Im also forced to set a description otherwise I am getting a discord API exception


Solution

  • You are recreating a new embed, use the embed of the message you fetched.

    (message) => {
      const embed = message.embeds[0]
        .setColor('#7bf542');
      message.edit({ embeds: [embed] });
    }