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:
parent
823238ee37
commit
2216b70e34
36
src/bot.py
36
src/bot.py
|
@ -10,6 +10,8 @@ __author__ = 'Bibin Muttappillil'
|
||||||
# standard library imports
|
# standard library imports
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
# discord imports
|
# discord imports
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -25,25 +27,37 @@ if TOKEN is None:
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('$b '))
|
bot = commands.Bot(command_prefix=commands.when_mentioned_or('$b '))
|
||||||
|
|
||||||
|
|
||||||
@bot.command(hidden=True)
|
@bot.event
|
||||||
@commands.is_owner()
|
async def on_command_error(ctx, error):
|
||||||
async def load(ctx, extension):
|
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
|
||||||
bot.load_extension(f'cogs.{extension}')
|
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
||||||
print(f'cogs.{extension} loaded')
|
await ctx.message.add_reaction('❌')
|
||||||
|
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_command_completion(ctx):
|
||||||
|
await ctx.message.add_reaction('✅')
|
||||||
|
|
||||||
|
|
||||||
@bot.command(hidden=True)
|
@bot.command(hidden=True)
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def unload(ctx, extension):
|
async def load(ctx, ext):
|
||||||
bot.unload_extension(f'cogs.{extension}')
|
bot.load_extension(f'cogs.{ext}')
|
||||||
print(f'cogs.{extension} unloaded')
|
print(f'cogs.{ext} loaded')
|
||||||
|
|
||||||
|
|
||||||
@bot.command(hidden=True)
|
@bot.command(hidden=True)
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def reload(ctx, extension):
|
async def unload(ctx, ext):
|
||||||
bot.reload_extension(f'cogs.{extension}')
|
bot.unload_extension(f'cogs.{ext}')
|
||||||
print(f'cogs.{extension} reloaded')
|
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']:
|
for extension in ['developer']:
|
||||||
|
|
Loading…
Reference in New Issue