From e9bacca70d376bd884be6c191a0386e82ec9b648 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Sat, 9 Jul 2016 11:40:27 -0500 Subject: [PATCH] Fixed global command error handling --- bot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index b4867b6..b2df4ca 100644 --- a/bot.py +++ b/bot.py @@ -31,21 +31,26 @@ async def on_ready(): cursor.execute('update restart_server set channel_id=0 where id=1') config.closeConnection() +@bot.event +async def on_message(message): + if message.author.bot: + return + await bot.process_commands(message) @bot.event async def on_member_join(member): - await bot.say("Welcome to the '{0.server.name}' server {0.mention}!".format(member)) + await bot.send_message(member.server,"Welcome to the '{0.server.name}' server {0.mention}!".format(member)) @bot.event async def on_member_remove(member): - await bot.say("{0} has left the server, I hope it wasn't because of something I said :c".format(member)) + await bot.send_message(member.server,"{0} has left the server, I hope it wasn't because of something I said :c".format(member)) @bot.event async def on_command_error(error, ctx): fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```' - await bot.say(fmt.format(type(error).__name__, error)) + await bot.send_message(ctx.message.channel,fmt.format(type(error).__name__, error)) if __name__ == '__main__': for e in extensions: