diff --git a/src/cogs/basic_game.py b/src/cogs/basic_game.py index 30a52fd..426a52d 100644 --- a/src/cogs/basic_game.py +++ b/src/cogs/basic_game.py @@ -4,6 +4,17 @@ 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""" @@ -14,6 +25,20 @@ class Cog(commands.Cog): 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"""