diff --git a/src/bot.py b/src/bot.py index 6bad9a9..60c1a4d 100644 --- a/src/bot.py +++ b/src/bot.py @@ -10,8 +10,6 @@ __author__ = 'Bibin Muttappillil' # standard library imports import os from dotenv import load_dotenv -import sys -import traceback # discord imports from discord.ext import commands @@ -26,41 +24,27 @@ if TOKEN is None: bot = commands.Bot(command_prefix=commands.when_mentioned_or('$b ')) +default_extensions = ['developer'] -@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 load(ctx, ext): - bot.load_extension(f'cogs.{ext}') - print(f'cogs.{ext} loaded') - - -@bot.command(hidden=True) -@commands.is_owner() -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']: +for extension in default_extensions: bot.load_extension(f'cogs.{extension}') +@bot.command() +@commands.is_owner() +async def load(ctx, extension): + bot.load_extension(f'cogs.{extension}') + print(f'cogs.{extension} loaded') + +@bot.command() +@commands.is_owner() +async def unload(ctx, extension): + bot.unload_extension(f'cogs.{extension}') + print(f'cogs.{extension} unloaded') + +@bot.command() +@commands.is_owner() +async def reload(ctx, extension): + bot.reload_extension(f'cogs.{extension}') + print(f'cogs.{extension} reloaded') + bot.run(TOKEN) diff --git a/src/cogs/basic_game.py b/src/cogs/basic_game.py deleted file mode 100644 index 426a52d..0000000 --- a/src/cogs/basic_game.py +++ /dev/null @@ -1,50 +0,0 @@ -"""A base module for integrating text games into a discord cog""" - -# import discord -from discord.ext import commands - - -# checks - - -def is_not(check): - return lambda ctx: not check(ctx) - - -def is_setup(ctx): - return ctx.channel in ctx.cog.sessions - - -class Cog(commands.Cog): - """A base game cog that has a collection of basic game commands and checkers""" - - def __init__(self, bot, session_cls=None): - self.bot = bot - self.sessions = {} - self.session_cls = Session if session_cls is None else session_cls - self.group = next(c for c in self.get_commands() if c.name == 'group') - self.group.name = self.qualified_name.lower() - - @commands.group(invoke_without_command=True) - async def group(self, ctx): - await ctx.send("try info") - - @group.command() - @commands.check(is_not(is_setup)) - async def setup(self, ctx): - """Creates a game instance for this channel""" - self.sessions[ctx.channel] = self.session_cls() - - @setup.error - async def setup_handler(self, ctx, error): - await ctx.send(f"A game of is already setup in this channel") - - -class Session: - """A base class for holding channel specific information and setting up a game""" - pass - - -class Display: - """A base class for displaying game in discord""" - pass