diff options
Diffstat (limited to 'commands.py')
-rw-r--r-- | commands.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/commands.py b/commands.py index a804469..44bc340 100644 --- a/commands.py +++ b/commands.py @@ -21,17 +21,17 @@ async def answer(ctx: commands.Context, msg: str, *args, **kwargs): def is_admin_channel(ctx: commands.Context): - print(ctx.message.channel,ctx.bot.admin_channel, ctx.message.channel == ctx.bot.admin_channel) return ctx.message.channel.id == ctx.bot.admin_channel @commands.command(help='display this help message', aliases=('hepl', 'h', '?')) async def help(ctx: commands.Context): command_doc = '\n'.join( - f' * {config.COMMAND_PREFIX}{c.name:15} - {c.help}' + f' • {config.COMMAND_PREFIX}{c.name:15} - {c.help}' for c in ctx.bot.commands) - await answer(ctx, f'''``` -{config.HELP_TEXT}\nThese are all available commands:\n{command_doc}```''') + doc = f'{config.HELP_TEXT}\nThese are all available commands:\n{command_doc}' + embed = discord.Embed(title="Hilfe", type="rich", description=doc, colour=discord.Colour.purple()) + await answer(ctx, '', embed=embed) @commands.command(help='create a new lobby', aliases=('create', 'inti', 'craete', 'cretae', 'c', 'i', '+')) @@ -144,8 +144,8 @@ async def stop(ctx: commands.Context, cancel_loop=True): await ctx.bot.destroy_pair_channels(ctx, meta_channel) -async def loop_cycle(ctx, t): - if not await shuffle(ctx, 3): +async def loop_cycle(ctx, t, g): + if not await shuffle(ctx, g): return False await asyncio.sleep(t) await ctx.bot.update_scores(ctx.guild) @@ -157,7 +157,7 @@ async def loop_cycle(ctx, t): help=f'repeat "shuffle" and "stop" <n> (default: {config.DEFAULT_LOOP_COUNT}) times and <t>' f' (default: {config.DEFAULT_LOOP_TIME}) seconds', aliases=('repeat', 'shuffleloop')) -async def loop(ctx: commands.Context, n=config.DEFAULT_LOOP_COUNT, t=config.DEFAULT_LOOP_TIME): +async def loop(ctx: commands.Context, n=config.DEFAULT_LOOP_COUNT, t=config.DEFAULT_LOOP_TIME, g=3): if not is_admin_channel(ctx): return try: n, t = int(n), int(t) @@ -166,7 +166,7 @@ async def loop(ctx: commands.Context, n=config.DEFAULT_LOOP_COUNT, t=config.DEFA return await answer(ctx, f'repeat shuffling {n} times and each {t} seconds') for _ in range(n): - result = await ctx.bot.await_coroutine(loop_cycle(ctx, t)) + result = await ctx.bot.await_coroutine(loop_cycle(ctx, t, g)) message = { 'cancelled': 'cancelled loop command', 'already running': 'cannot start loop, another task is running...' @@ -239,5 +239,14 @@ async def scoreboard(ctx: commands.Context): embed = discord.Embed(title=config.SCOREBOARD_TITLE, type="rich", description=text, colour=discord.Colour.purple()) await ctx.send(embed=embed) +@commands.command( + help='reset the scoreboard', + aliases=(), +) +async def reset(ctx: commands.Context): + if is_admin_channel(ctx): + ctx.bot.reset_scoreboard() + await answer(ctx, 'resetted the scoreboard') + bot_commands = [cmd for cmd in locals().values() if isinstance(cmd, commands.Command)] |