-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathexceptions.py
44 lines (25 loc) · 1.48 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from collections.abc import Container
from discord.ext.commands import CheckFailure
class JamCategoryNameConflictError(Exception):
"""Raised when upon creating a CodeJam the main jam category and the teams' category conflict."""
class SilentCheckFailure(CheckFailure):
"""Raised when a check fails, but the bot should not give feedback."""
class CodeJamCategoryCheckFailure(SilentCheckFailure):
"""Raised when the specified command was run outside the Code Jam categories."""
class InMonthCheckFailure(CheckFailure):
"""Check failure for when a command is invoked outside of its allowed month."""
class SilentChannelFailure(SilentCheckFailure):
"""Raised when someone should not use a command in a context and should silently fail."""
class SilentRoleFailure(SilentCheckFailure):
"""Raised when someone doesn't have the correct role to use a command and should silently fail."""
class InWhitelistCheckFailure(CheckFailure):
"""Raised when the `in_whitelist` check fails."""
def __init__(self, redirect_channels: Container[int] | None):
self.redirect_channels = redirect_channels
if redirect_channels:
channels = ">, <#".join([str(channel) for channel in redirect_channels])
redirect_message = f" here. Please use the <#{channels}> channel(s) instead"
else:
redirect_message = ""
error_message = f"You are not allowed to use that command{redirect_message}."
super().__init__(error_message)