diff --git a/src/bot.py b/src/bot.py index 37eed11..6bad9a9 100644 --- a/src/bot.py +++ b/src/bot.py @@ -10,6 +10,8 @@ __author__ = 'Bibin Muttappillil' # standard library imports import os from dotenv import load_dotenv +import sys +import traceback # discord imports from discord.ext import commands @@ -25,25 +27,37 @@ if TOKEN is None: bot = commands.Bot(command_prefix=commands.when_mentioned_or('$b ')) -@bot.command(hidden=True) -@commands.is_owner() -async def load(ctx, extension): - bot.load_extension(f'cogs.{extension}') - print(f'cogs.{extension} loaded') +@bot.event +async def on_command_error(ctx, error): + print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr) + traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr) + await ctx.message.add_reaction('❌') + + +@bot.event +async def on_command_completion(ctx): + await ctx.message.add_reaction('✅') @bot.command(hidden=True) @commands.is_owner() -async def unload(ctx, extension): - bot.unload_extension(f'cogs.{extension}') - print(f'cogs.{extension} unloaded') +async def load(ctx, ext): + bot.load_extension(f'cogs.{ext}') + print(f'cogs.{ext} loaded') @bot.command(hidden=True) @commands.is_owner() -async def reload(ctx, extension): - bot.reload_extension(f'cogs.{extension}') - print(f'cogs.{extension} reloaded') +async def unload(ctx, ext): + bot.unload_extension(f'cogs.{ext}') + print(f'cogs.{ext} unloaded') + + +@bot.command(hidden=True) +@commands.is_owner() +async def reload(ctx, ext): + bot.reload_extension(f'cogs.{ext}') + print(f'cogs.{ext} reloaded') for extension in ['developer']: