0
votes

I'm trying to edit an embed message that has already been sent (serves as a role reaction message). For example: I type "roles" and get an embed message that assigns roles when reacted to. I want to edit it to add another role in the description without sending an entirely new message. MEE6 bot is able to this so I'm sure it's possible. I found code that should work:

# This sends an embed message with a description of the roles.
@client.event
async def on_message(message):
    if message.channel.id == 700895165665247325:
        if message.content.startswith('roles'):
            embedvar = discord.Embed(title="React to this message to get your roles!",
                                     description="Click the corresponding emoji to receive your role.\n<:WarThunder:"
                                                 "745425772944162907> - War Thunder\n<:Apex:745425965764575312> - "
                                                 "Apex\n<:ModernWarfare:757104623738814554> - "
                                                 "Modern Warfare\n<:Minecraft:757029546632413346> - "
                                                 "Minecraft\n<:R6Siege:757030019909550122> - R6 Siege", color=0x00ff00)
            embedvar2 = discord.Embed(title="React to this message to get your roles!",
                                      description="Click the corresponding emoji to receive your role.\n<:WarThunder:"
                                                  "745425772944162907> - War Thunder\n<:Apex:745425965764575312> - "
                                                  "Apex\n<:ModernWarfare:757104623738814554> - "
                                                  "Modern Warfare\n<:Minecraft:757029546632413346> - "
                                                  "Minecraft\n<:R6Siege:757030019909550122> - R6 Siege\n"
                                                  "<:AmongUs:760192601625591859> - Among Us", color=0x00ff00)
            await message.channel.send(embed=embedvar)
            await message.edit(embed=embedvar2)
            print("Changed message embed color.")
    else:
        return

Yet it gives me this error:

discord.errors.Forbidden: 403 Forbidden (error code: 50005): Cannot edit a message authored by another user

Yes, the bot has all the correct permissions and is assigning ranks lower on the hierarchy than it.

2

2 Answers

0
votes

You are trying to edit the message that was passed by the event, try:

msg = await message.channel.send(embed=embedvar)
await msg.edit(embed=embedvar2)
0
votes

Here's the working code:

# This sends an embed message with a description of the roles.
@client.event
async def on_message(message):
    if message.channel.id == 700895165665247325:
        if message.content.startswith('roles'):
            embedvar = discord.Embed(title="React to this message to get your roles!",
                                     description="Click the corresponding emoji to receive your role.\n<:WarThunder:"
                                                 "745425772944162907> - War Thunder\n<:Apex:745425965764575312> - "
                                                 "Apex\n<:ModernWarfare:757104623738814554> - "
                                                 "Modern Warfare\n<:Minecraft:757029546632413346> - "
                                                 "Minecraft\n<:R6Siege:757030019909550122> - R6 Siege", color=0x00ff00)
            await message.channel.send(embed=embedvar)
            print("Changed message embed color.")
        elif message.content.startswith('update'):
            embedvar2 = discord.Embed(title="React to this message to get your roles!",
                                      description="Click the corresponding emoji to receive your role.\n<:WarThunder:"
                                                  "745425772944162907> - War Thunder\n<:Apex:745425965764575312> - "
                                                  "Apex\n<:ModernWarfare:757104623738814554> - "
                                                  "Modern Warfare\n<:Minecraft:757029546632413346> - "
                                                  "Minecraft\n<:R6Siege:757030019909550122> - R6 Siege\n"
                                                  "<:AmongUs:760192601625591859> - Among Us", color=0x00ff00)
            channel = client.get_channel(700895165665247325)
            msg = await channel.fetch_message(757114312413151272)
            await msg.edit(embed=embedvar2)
            print("Updated role reaction message.")
    else:
        return

I simply type "update" into the correct channel and whatever is in embedvar2 is what the message is updated with.