我有一个小问题,我不知道如何解决。我想编辑嵌入的消息,如果它被发布,则直接由不和谐网络钩子发送。所以这就是我为此使用 'on_message' 事件的原因。在正常情况下,您可以只获取消息,然后使用 msg.edit
,但这不适用于 webhook 消息。
如何在发布时直接从 webhook 编辑消息?我尝试使用 api“discord-webhooks”,但找不到我想要的解决方案。
我试过了:
@bot.event
async def on_message(message):
##### Netflix-News edit ######
if message.channel.id == 804484025166856262:
embed = discord.Embed(title=f"{title}",
url=f"{lonk}",
description=f"{descfix}",
color=0xe74c3c)
embed.set_thumbnail(url=f"https://i.imgur.com/4np2bdK.png")
embed.set_image(url=f"{Thumbnail}")
embed.set_footer(text=f"{footer}", icon_url="https://i.imgur.com/4np2bdK.png")
webhook = DiscordWebhook(url='LINKHERE')
webhook.embed = embed
await webhook.edit(sent_webhook)
答案 0 :(得分:1)
Webhook.edit
编辑 webhook 本身,而不是消息。要编辑消息,请使用 Webhook.edit_message
await webhook.edit_message(message_id, embed=embed)
PS:您没有定义 sent_webhook