diff options
| -rw-r--r-- | bot/cogs/bigbrother.py | 12 | ||||
| -rw-r--r-- | bot/cogs/events.py | 12 | ||||
| -rw-r--r-- | bot/cogs/filtering.py | 10 | ||||
| -rw-r--r-- | bot/cogs/tags.py | 3 | ||||
| -rw-r--r-- | config-default.yml | 12 | 
5 files changed, 33 insertions, 16 deletions
diff --git a/bot/cogs/bigbrother.py b/bot/cogs/bigbrother.py index 7964c81a8..29b13f038 100644 --- a/bot/cogs/bigbrother.py +++ b/bot/cogs/bigbrother.py @@ -216,11 +216,12 @@ class BigBrother:      @bigbrother_group.command(name='watch', aliases=('w',))      @with_role(Roles.owner, Roles.admin, Roles.moderator) -    async def watch_command(self, ctx: Context, user: User, *, reason: str = None): +    async def watch_command(self, ctx: Context, user: User, *, reason: str):          """          Relay messages sent by the given `user` to the `#big-brother-logs` channel -        If a `reason` is specified, a note is added for `user` +        A `reason` for watching is required, which is added for the user to be watched as a +        note (aka: shadow warning)          """          channel_id = Channels.big_brother_logs @@ -251,10 +252,9 @@ class BigBrother:                  reason = data.get('error_message', "no message provided")                  await ctx.send(f":x: the API returned an error: {reason}") -        # Add a note (shadow warning) if a reason is specified -        if reason: -            reason = "bb watch: " + reason  # Prepend for situational awareness -            await post_infraction(ctx, user, type="warning", reason=reason, hidden=True) +        # Add a note (shadow warning) with the reason for watching +        reason = "bb watch: " + reason  # Prepend for situational awareness +        await post_infraction(ctx, user, type="warning", reason=reason, hidden=True)      @bigbrother_group.command(name='unwatch', aliases=('uw',))      @with_role(Roles.owner, Roles.admin, Roles.moderator) diff --git a/bot/cogs/events.py b/bot/cogs/events.py index 3537c850a..edfc6e579 100644 --- a/bot/cogs/events.py +++ b/bot/cogs/events.py @@ -3,8 +3,8 @@ import logging  from discord import Colour, Embed, Member, Object  from discord.ext.commands import (      BadArgument, Bot, BotMissingPermissions, -    CommandError, CommandInvokeError, Context, -    NoPrivateMessage, UserInputError +    CommandError, CommandInvokeError, CommandNotFound, +    Context, NoPrivateMessage, UserInputError  )  from bot.cogs.modlog import ModLog @@ -121,7 +121,13 @@ class Events:              log.debug(f"Command {command} has a local error handler, ignoring.")              return -        if isinstance(e, BadArgument): +        if isinstance(e, CommandNotFound) and not hasattr(ctx, "invoked_from_error_handler"): +            tags_get_command = self.bot.get_command("tags get") +            ctx.invoked_from_error_handler = True + +            # Return to not raise the exception +            return await ctx.invoke(tags_get_command, tag_name=ctx.invoked_with) +        elif isinstance(e, BadArgument):              await ctx.send(f"Bad argument: {e}\n")              await ctx.invoke(*help_command)          elif isinstance(e, UserInputError): diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py index a8b5091af..b6ce501fc 100644 --- a/bot/cogs/filtering.py +++ b/bot/cogs/filtering.py @@ -238,7 +238,15 @@ class Filtering:                  f"{URLs.discord_invite_api}/{invite}"              )              response = await response.json() -            guild_id = int(response.get("guild", {}).get("id")) +            if response.get("guild") is None: +                # If we have a valid invite which is not a guild invite +                # it might be a DM channel invite +                if response.get("channel") is not None: +                    # We don't have whitelisted Group DMs so we can +                    # go ahead and return a positive for any group DM +                    return True + +            guild_id = int(response.get("guild").get("id"))              if guild_id not in Filter.guild_invite_whitelist:                  return True diff --git a/bot/cogs/tags.py b/bot/cogs/tags.py index ba4edeef7..8ecd80127 100644 --- a/bot/cogs/tags.py +++ b/bot/cogs/tags.py @@ -180,6 +180,9 @@ class Tags:                  if tag_data['image_url'] is not None:                      embed.set_image(url=tag_data['image_url']) +        # If its invoked from error handler just ignore it. +        elif hasattr(ctx, "invoked_from_error_handler"): +            return          # If not, prepare an error message.          else:              embed.colour = Colour.red() diff --git a/config-default.yml b/config-default.yml index 41383a6ae..e7145289d 100644 --- a/config-default.yml +++ b/config-default.yml @@ -19,13 +19,13 @@ style:      emojis:          defcon_disabled: "<:defcondisabled:470326273952972810>" -        defcon_enabled: "<:defconenabled:470326274213150730>" -        defcon_updated: "<:defconsettingsupdated:470326274082996224>" +        defcon_enabled:  "<:defconenabled:470326274213150730>" +        defcon_updated:  "<:defconsettingsupdated:470326274082996224>"          green_chevron: "<:greenchevron:418104310329769993>"          red_chevron:   "<:redchevron:418112778184818698>"          white_chevron: "<:whitechevron:418110396973711363>" -        lemoneye2:     "<:lemoneye2:435193765582340098>" +        bb_message:    "<:bbmessage:472476937504423936>"          status_online:  "<:status_online:470326272351010816>"          status_idle:    "<:status_idle:470326266625785866>" @@ -42,7 +42,7 @@ style:          crown_green:   "https://cdn.discordapp.com/emojis/469964154719961088.png"          crown_red:     "https://cdn.discordapp.com/emojis/469964154879344640.png" -        defcon_denied:  "https://cdn.discordapp.com/emojis/472475292078964738.png" +        defcon_denied:   "https://cdn.discordapp.com/emojis/472475292078964738.png"          defcon_disabled: "https://cdn.discordapp.com/emojis/470326273952972810.png"          defcon_enabled:  "https://cdn.discordapp.com/emojis/470326274213150730.png"          defcon_updated:  "https://cdn.discordapp.com/emojis/472472638342561793.png" @@ -68,8 +68,8 @@ style:          user_unban:  "https://cdn.discordapp.com/emojis/469952898692808704.png"          user_update: "https://cdn.discordapp.com/emojis/469952898684551168.png" -        user_mute:   "https://cdn.discordapp.com/emojis/472472640100106250.png" -        user_unmute: "https://cdn.discordapp.com/emojis/472472639206719508.png" +        user_mute:     "https://cdn.discordapp.com/emojis/472472640100106250.png" +        user_unmute:   "https://cdn.discordapp.com/emojis/472472639206719508.png"          user_verified: "https://cdn.discordapp.com/emojis/470326274519334936.png"          pencil: "https://cdn.discordapp.com/emojis/470326272401211415.png"  |