1
0
Fork 0
mirror of synced 2024-05-19 20:12:30 +12:00

Fixed global command error handling

This commit is contained in:
Phxntxm 2016-07-09 11:40:27 -05:00
parent 28b47d2a13
commit e9bacca70d

11
bot.py
View file

@ -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: