aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Thomas Petersson <[email protected]>2019-01-30 23:08:36 +0100
committerGravatar GitHub <[email protected]>2019-01-30 23:08:36 +0100
commit34f14b5da34d4f4766c41cf9fb92335b4720f1bc (patch)
tree089a4205e71f53a376cdd2482b1cec85db7f1775
parentFixed a few urls pointing to wikipedie file instead of image url (diff)
parentMerge pull request #296 from python-discord/redirect-decorator-handling-delet... (diff)
Merge branch 'master' into superstarifyimprovements
-rw-r--r--bot/decorators.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bot/decorators.py b/bot/decorators.py
index 0e372671a..1ba2cd59e 100644
--- a/bot/decorators.py
+++ b/bot/decorators.py
@@ -2,10 +2,12 @@ import logging
import random
import typing
from asyncio import Lock, sleep
+from contextlib import suppress
from functools import wraps
from weakref import WeakValueDictionary
from discord import Colour, Embed
+from discord.errors import NotFound
from discord.ext import commands
from discord.ext.commands import CheckFailure, Context
@@ -134,7 +136,13 @@ def redirect_output(destination_channel: int, bypass_roles: typing.Container[int
if RedirectOutput.delete_invocation:
await sleep(RedirectOutput.delete_delay)
- await message.delete()
- await ctx.message.delete()
+
+ with suppress(NotFound):
+ await message.delete()
+ log.trace("Redirect output: Deleted user redirection message")
+
+ with suppress(NotFound):
+ await ctx.message.delete()
+ log.trace("Redirect output: Deleted invocation message")
return inner
return wrap