mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-12 16:50:10 +00:00
Fix special case where webhook is deleted by user
This commit is contained in:
parent
a4449ceaae
commit
899183f26d
1 changed files with 15 additions and 7 deletions
|
|
@ -103,13 +103,21 @@ async def do_proxy_message(conn, original_message: discord.Message, proxy_member
|
||||||
inner_text: str, logger: ChannelLogger):
|
inner_text: str, logger: ChannelLogger):
|
||||||
# Send the message through the webhook
|
# Send the message through the webhook
|
||||||
webhook = await get_or_create_webhook_for_channel(conn, original_message.channel)
|
webhook = await get_or_create_webhook_for_channel(conn, original_message.channel)
|
||||||
sent_message = await webhook.send(
|
|
||||||
content=inner_text,
|
try:
|
||||||
username=proxy_member.name,
|
sent_message = await webhook.send(
|
||||||
avatar_url=proxy_member.avatar_url,
|
content=inner_text,
|
||||||
file=await make_attachment_file(original_message),
|
username=proxy_member.name,
|
||||||
wait=True
|
avatar_url=proxy_member.avatar_url,
|
||||||
)
|
file=await make_attachment_file(original_message),
|
||||||
|
wait=True
|
||||||
|
)
|
||||||
|
except discord.NotFound:
|
||||||
|
# The webhook we got from the DB doesn't actually exist
|
||||||
|
# If we delete it from the DB then call the function again, it'll re-create one for us
|
||||||
|
await db.delete_webhook(conn, original_message.channel.id)
|
||||||
|
await do_proxy_message(conn, original_message, proxy_member, inner_text, logger)
|
||||||
|
return
|
||||||
|
|
||||||
# Save the proxied message in the database
|
# Save the proxied message in the database
|
||||||
await db.add_message(conn, sent_message.id, original_message.channel.id, proxy_member.id,
|
await db.add_message(conn, sent_message.id, original_message.channel.id, proxy_member.id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue