Feat: Add emoji confirming/error reactions

If the commands throws an error then the bot marks the command message with a cross emoji reaction otherwise it adds a check mark.
(Also resolved some overshadowing warning of extension)
This commit is contained in:
Bibin Muttappillil 2021-01-04 02:32:45 +01:00
parent 823238ee37
commit 2216b70e34
1 changed files with 25 additions and 11 deletions

View File

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