diff --git a/cogs/core.py b/cogs/core.py index 2947f34..82b1e86 100644 --- a/cogs/core.py +++ b/cogs/core.py @@ -107,14 +107,10 @@ class Core: dice = re.search("(\d*)d(\d*)", notation).group(1) num = int(re.search("(\d*)d(\d*)", notation).group(2)) # This error will be hit if the notation is completely different than #d# - except AttributeError: - await self.bot.say("Please provide the die notation in #d#!") - return - # This error will be hit if there was an issue converting to an int - # This means the notation was still given wrong - except ValueError: + except (AttributeError, ValueError): await self.bot.say("Please provide the die notation in #d#!") return + # Dice will be None if d# was provided, assume this means 1d# dice = dice or 1 dice = int(dice) diff --git a/cogs/links.py b/cogs/links.py index 3451d36..c69c0b2 100644 --- a/cogs/links.py +++ b/cogs/links.py @@ -37,7 +37,8 @@ class Links: if len(search) > 0: # This sets the url as url?q=search+terms url = 'https://derpibooru.org/search.json?q={}'.format('+'.join(search)) - if ctx.message.channel.id in config.getContent("nsfw_channels"): + nsfw_channels = config.getContent("nsfw_channels") or {} + if ctx.message.channel.id in nsfw_channels: url += ",+explicit&filter_id=95938" # Get the response from derpibooru and parse the 'search' result from it @@ -78,7 +79,8 @@ class Links: url = 'https://e621.net/post/index.json?limit=320&tags={}'.format(tags) await self.bot.say("Looking up an image with those tags....") - if ctx.message.channel.id in config.getContent('nsfw_channels'): + nsfw_channels = config.getContent("nsfw_channels") or {} + if ctx.message.channel.id in nsfw_channels: url += "%20rating:explicit" else: url += "%20rating:safe"