From 656990686be98e18363bbf8dd54a31a413e1b8fa Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Mon, 11 Jul 2016 07:40:03 -0500 Subject: [PATCH] Added error handling for bad arguments --- bot.py | 3 +++ cogs/twitch.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 5f26e41..85a7f92 100644 --- a/bot.py +++ b/bot.py @@ -54,6 +54,9 @@ async def on_command_error(error, ctx): if isinstance(error, commands.CommandNotFound): fmt = "That is not a valid command! If you need asistance on what command to use, please enter '!help'" await bot.send_message(ctx.message.channel, fmt) + elif isinstance(error, commands.BadArgument): + fmt = "Please provide a valid argument to pass to the command: {}:".format(error) + await bot.send_message(ctx.message.channel, fmt) else: fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```' await bot.send_message(ctx.message.channel, fmt.format(type(error).__name__, error)) diff --git a/cogs/twitch.py b/cogs/twitch.py index 420bbe4..9a68d05 100644 --- a/cogs/twitch.py +++ b/cogs/twitch.py @@ -36,7 +36,7 @@ async def checkChannels(bot): await bot.send_message(server, "{} has just gone offline! Catch them next time they stream at {}" .format(member.name, url)) config.closeConnection() - await asyncio.sleep(180) + await asyncio.sleep(60) class Twitch: @@ -117,7 +117,7 @@ class Twitch: ctx.message.author.mention)) config.closeConnection() - @commands.group(pass_context=True, no_pm=True, invoke_without_command=True) + @twitch.group(pass_context=True, no_pm=True, invoke_without_command=True) async def notify(self, ctx): """This can be used to turn notifications on or off""" pass