我正在尝试编辑已发送的嵌入消息(用作角色响应消息)。例如:我键入“角色”并获得一条嵌入消息,该消息在做出反应时会分配角色。我想对其进行编辑以在描述中添加其他角色,而不发送全新的消息。 MEE6 bot能够做到这一点,因此我确信这是可能的。我发现应该起作用的代码:
# 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
但是它给了我这个错误:
discord.errors.Forbidden: 403 Forbidden (error code: 50005): Cannot edit a message authored by another user
是的,该漫游器拥有所有正确的权限,并且在层次结构上分配的排名比其低。
答案 0 :(得分:0)
您正在尝试编辑事件传递的message
,请尝试:
msg = await message.channel.send(embed=embedvar)
await msg.edit(embed=embedvar2)
答案 1 :(得分:0)
这是工作代码:
embedvar2
我只需在正确的频道中键入“更新”,然后df.replace
中的内容即会更新消息。