Home > database >  Discord.js change embed color without erasing all other content
Discord.js change embed color without erasing all other content

Time:07-31

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

CodePudding user response:

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] });
}
  • Related