"""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