Compare commits

..

No commits in common. "2216b70e3414365d1299eddaf2527f49f19b7543" and "91f96ce246730dd669d459e9ecb9e354e653afd6" have entirely different histories.

2 changed files with 20 additions and 86 deletions

View File

@ -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)

View File

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