Guacamole15
Guacamole15

Reputation: 39

Discord.js Edit embed

I am trying to edit an embed sent previously by the bot with updated roles but it gives the error in discord v12
DiscordAPIError: Cannot edit a message authored by another user

What the message is that I am trying to edit

if(message.content === "editroles"){
        let embed = new discord.MessageEmbed()
            .setTitle('Server Events')
            .setDescription('Announcements:\nReact with 📢 to get pinged for announcements!\n\nEvents:\nReact with 🎙️ to get pinged for server events!\n\nPolls:\nReact with 📊 to get pinged for daily polls!')
            .setColor('DARK_BUT_NOT_BLACK')
        message.channel.messages.fetch({around: '806426175609110529', limit: 1})
        .then(msg => {
            const embededit = msg.first()
            embededit.edit(embed);
        })
    }

Upvotes: 1

Views: 1043

Answers (1)

PLASMA chicken
PLASMA chicken

Reputation: 2785

Try to use:

message.channel.messages.fetch('806426175609110529')

This fetches the Message Directly and makes sure it is always the message with that exact id.

If this errors, it could be that message.channel is not the same channel where the embed was sent.

I played around with around: and it seems to not be 100% reliable.

Upvotes: 3

Related Questions