aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2018-12-27 21:18:00 +0100
committerGravatar GitHub <[email protected]>2018-12-27 21:18:00 +0100
commit79e7e0a9be3c44d213e01aca0d0bb300365be77d (patch)
tree8efb2ec0bfdf21b9c2502d64479832870d53094c
parentPing mod on infr notify failure in modlog. (diff)
parentMerge pull request #226 from python-discord/group-dm-invites (diff)
Merge branch 'master' into mod-dm-status
-rw-r--r--bot/cogs/events.py12
-rw-r--r--bot/cogs/filtering.py10
-rw-r--r--bot/cogs/tags.py3
3 files changed, 21 insertions, 4 deletions
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 a0ba7fdd1..b128b6de1 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()