diff options
| author | 2019-09-25 17:20:17 -0700 | |
|---|---|---|
| committer | 2019-09-25 17:20:17 -0700 | |
| commit | 485b49b70b3bfe6d6abf2227336cd9f0aa7a4563 (patch) | |
| tree | f2b7e4f1c47257fed6145b1e1388d1a39a874904 | |
| parent | Note Type Correction (diff) | |
Fix AttributeError with cog special methods
Discord.py's internals use the __func__ attribute of special methods
(cog_command_error, cog_check, cog_before_invoke, cog_after_invoke).
Therefore the methods must be bound methods rather than static so that
the attribute exists.
| -rw-r--r-- | bot/cogs/moderation.py | 4 | ||||
| -rw-r--r-- | bot/cogs/verification.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py index f2ff7e6b2..2ad5b96f4 100644 --- a/bot/cogs/moderation.py +++ b/bot/cogs/moderation.py @@ -1282,8 +1282,8 @@ class Moderation(Scheduler, Cog): # endregion - @staticmethod - async def cog_command_error(ctx: Context, error: Exception) -> None: + # This cannot be static (must have a __func__ attribute). + async def cog_command_error(self, ctx: Context, error: Exception) -> None: """Send a notification to the invoking context on a Union failure.""" if isinstance(error, BadUnionArgument): if User in error.converters: diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py index b0c250603..f0a099f27 100644 --- a/bot/cogs/verification.py +++ b/bot/cogs/verification.py @@ -141,8 +141,8 @@ class Verification(Cog): f"{ctx.author.mention} Unsubscribed from <#{Channels.announcements}> notifications." ) - @staticmethod - async def cog_command_error(ctx: Context, error: Exception) -> None: + # This cannot be static (must have a __func__ attribute). + async def cog_command_error(self, ctx: Context, error: Exception) -> None: """Check for & ignore any InChannelCheckFailure.""" if isinstance(error, InChannelCheckFailure): error.handled = True |