diff options
author | NatrixAeria <upezu@student.kit.edu> | 2020-10-19 17:09:33 +0200 |
---|---|---|
committer | NatrixAeria <upezu@student.kit.edu> | 2020-10-19 17:09:33 +0200 |
commit | 1cd2075a42d422c81f31a4341f208b542bb9139f (patch) | |
tree | fbd7adcec5b12c8329649ca68db0b92d45b46a1b /commands.py | |
parent | 867d9fe61528de345e6b0ce38b49771002d8fe3a (diff) |
Add scoring system
Diffstat (limited to 'commands.py')
-rw-r--r-- | commands.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/commands.py b/commands.py index e9982aa..feb6c74 100644 --- a/commands.py +++ b/commands.py @@ -76,6 +76,7 @@ async def shuffle(ctx: commands.Context, channel_size=2): normals.append(member) futures = [] ctx.bot.pair_channels = await ctx.bot.create_pair_channels(ctx, meta_channel, channel_count) + random.shuffle(ctx.bot.pair_channels) groups = [[] for _ in range(channel_count)] for i, member in enumerate(tutors + normals): n = i % channel_count @@ -109,6 +110,7 @@ async def loop_cycle(ctx, t): if not await shuffle(ctx): return False await asyncio.sleep(t) + await ctx.bot.update_scores(ctx.guild) await stop(ctx, cancel_loop=False) return True @@ -123,7 +125,7 @@ async def loop(ctx: commands.Context, n=config.DEFAULT_LOOP_COUNT, t=config.DEFA except ValueError: await answer(ctx, 'error: expecting positive integer arguments for <n> and <t> (e.g. "loop 5 60" to repeat 5 times)') return - await answer(ctx, f'error: repeat shuffling {n} times and each {t} seconds') + 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)) message = { @@ -170,14 +172,14 @@ async def remove(ctx: commands.Context, id=None): ) async def list(ctx: commands.Context): if ctx.bot.tutors: - futures = [] + users = [] for tutor in ctx.bot.tutors: try: user = ctx.bot.get_user(tutor) or await ctx.bot.fetch_user(tutor) - futures.append(answer(ctx, f' • {user} ({tutor})')) + users.append((str(user), tutor)) except Exception as e: - futures.append(await answer(ctx, f' • *unknown* ({tutor})')) - await await_n(futures) + users.append(('*unknown*', tutor)) + await answer(ctx, '```\n' + '\n'.join(f' • {name} ({id})' for name, id in users) + '\n```') else: await answer(ctx, 'there is no tutor :/') |