diff options
Diffstat (limited to 'bot/exts/backend')
-rw-r--r-- | bot/exts/backend/branding/_cog.py | 2 | ||||
-rw-r--r-- | bot/exts/backend/config_verifier.py | 4 | ||||
-rw-r--r-- | bot/exts/backend/error_handler.py | 37 |
3 files changed, 24 insertions, 19 deletions
diff --git a/bot/exts/backend/branding/_cog.py b/bot/exts/backend/branding/_cog.py index ff2704835..94429c172 100644 --- a/bot/exts/backend/branding/_cog.py +++ b/bot/exts/backend/branding/_cog.py @@ -325,7 +325,7 @@ class Branding(commands.Cog): # Notify guild of new event ~ this reads the information that we cached above. if event_changed and not event.meta.is_fallback: - await self.send_info_embed(Channels.change_log, is_notification=True) + await self.send_info_embed(Channels.changelog, is_notification=True) else: log.trace("Omitting #changelog notification. Event has not changed, or new event is fallback.") diff --git a/bot/exts/backend/config_verifier.py b/bot/exts/backend/config_verifier.py index 97c8869a1..84ae5ca92 100644 --- a/bot/exts/backend/config_verifier.py +++ b/bot/exts/backend/config_verifier.py @@ -24,12 +24,12 @@ class ConfigVerifier(Cog): server_channel_ids = {channel.id for channel in server.channels} invalid_channels = [ - channel_name for channel_name, channel_id in constants.Channels + (channel_name, channel_id) for channel_name, channel_id in constants.Channels if channel_id not in server_channel_ids ] if invalid_channels: - log.warning(f"Configured channels do not exist in server: {', '.join(invalid_channels)}.") + log.warning(f"Configured channels do not exist in server: {invalid_channels}.") async def setup(bot: Bot) -> None: diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py index 07248df5b..8883f7566 100644 --- a/bot/exts/backend/error_handler.py +++ b/bot/exts/backend/error_handler.py @@ -1,7 +1,7 @@ import copy import difflib -from discord import Embed +from discord import Embed, Member from discord.ext.commands import ChannelNotFound, Cog, Context, TextChannelConverter, VoiceChannelConverter, errors from pydis_core.site_api import ResponseCodeError from sentry_sdk import push_scope @@ -167,28 +167,33 @@ class ErrorHandler(Cog): by `on_command_error`, but the `invoked_from_error_handler` attribute will be added to the context to prevent infinite recursion in the case of a CommandNotFound exception. """ - tags_get_command = self.bot.get_command("tags get") - if not tags_get_command: - log.debug("Not attempting to parse message as a tag as could not find `tags get` command.") + tags_cog = self.bot.get_cog("Tags") + if not tags_cog: + log.debug("Not attempting to parse message as a tag as could not find `Tags` cog.") return + tags_get_command = tags_cog.get_command_ctx - ctx.invoked_from_error_handler = True + maybe_tag_name = ctx.invoked_with + if not maybe_tag_name or not isinstance(ctx.author, Member): + return - log_msg = "Cancelling attempt to fall back to a tag due to failed checks." + ctx.invoked_from_error_handler = True try: - if not await tags_get_command.can_run(ctx): - log.debug(log_msg) + if not await self.bot.can_run(ctx): + log.debug("Cancelling attempt to fall back to a tag due to failed checks.") return - except errors.CommandError as tag_error: - log.debug(log_msg) - await self.on_command_error(ctx, tag_error) - return - if await ctx.invoke(tags_get_command, argument_string=ctx.message.content): - return + if await tags_get_command(ctx, maybe_tag_name): + return - if not any(role.id in MODERATION_ROLES for role in ctx.author.roles): - await self.send_command_suggestion(ctx, ctx.invoked_with) + if not any(role.id in MODERATION_ROLES for role in ctx.author.roles): + await self.send_command_suggestion(ctx, maybe_tag_name) + except Exception as err: + log.debug("Error while attempting to invoke tag fallback.") + if isinstance(err, errors.CommandError): + await self.on_command_error(ctx, err) + else: + await self.on_command_error(ctx, errors.CommandInvokeError(err)) async def try_run_fixed_codeblock(self, ctx: Context) -> bool: """ |