Fix special case where webhook is deleted by user
This commit is contained in:
parent
a4449ceaae
commit
899183f26d
@ -103,6 +103,8 @@ async def do_proxy_message(conn, original_message: discord.Message, proxy_member
|
||||
inner_text: str, logger: ChannelLogger):
|
||||
# Send the message through the webhook
|
||||
webhook = await get_or_create_webhook_for_channel(conn, original_message.channel)
|
||||
|
||||
try:
|
||||
sent_message = await webhook.send(
|
||||
content=inner_text,
|
||||
username=proxy_member.name,
|
||||
@ -110,6 +112,12 @@ async def do_proxy_message(conn, original_message: discord.Message, proxy_member
|
||||
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
|
||||
await db.add_message(conn, sent_message.id, original_message.channel.id, proxy_member.id,
|
||||
|
Loading…
Reference in New Issue
Block a user