aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-09-14 17:41:11 -0700
committerGravatar MarkKoz <[email protected]>2019-09-14 19:05:44 -0700
commit45a4fb55498230177ae8cadb3e308adcfa755443 (patch)
treed41e6f95ba654b1224fd96884941f3c9643a1423
parentActually fix cog error handler check when command is None (diff)
Generate InChannelCheckFailure's message inside the exception
The exception now expects channel IDs to be passed to it.
-rw-r--r--bot/decorators.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/bot/decorators.py b/bot/decorators.py
index 1ba2cd59e..923d21938 100644
--- a/bot/decorators.py
+++ b/bot/decorators.py
@@ -18,7 +18,11 @@ log = logging.getLogger(__name__)
class InChannelCheckFailure(CheckFailure):
- pass
+ def __init__(self, *channels: int):
+ self.channels = channels
+ channels_str = ', '.join(f"<#{c_id}>" for c_id in channels)
+
+ super().__init__(f"Sorry, but you may only use this command within {channels_str}.")
def in_channel(*channels: int, bypass_roles: typing.Container[int] = None):
@@ -41,10 +45,7 @@ def in_channel(*channels: int, bypass_roles: typing.Container[int] = None):
log.debug(f"{ctx.author} tried to call the '{ctx.command.name}' command. "
f"The in_channel check failed.")
- channels_str = ', '.join(f"<#{c_id}>" for c_id in channels)
- raise InChannelCheckFailure(
- f"Sorry, but you may only use this command within {channels_str}."
- )
+ raise InChannelCheckFailure(*channels)
return commands.check(predicate)