From 4cd4fab68f0c8f48bdd666b48a8408cca54ff368 Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 11 Jan 2022 10:32:30 +0200 Subject: [PATCH] (timer): Various bugfixes. --- bot/modules/study/timers/Timer.py | 5 ++++- bot/modules/study/timers/commands.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bot/modules/study/timers/Timer.py b/bot/modules/study/timers/Timer.py index cbfbaa2d..9fd97f51 100644 --- a/bot/modules/study/timers/Timer.py +++ b/bot/modules/study/timers/Timer.py @@ -325,6 +325,9 @@ class Timer: """ Remove the timer. """ + # Remove timer from cache + self.timers.pop(self.channelid) + # Cancel the loop if self._run_task: self._run_task.cancel() @@ -424,5 +427,5 @@ async def touch_member(client, member, before, after): await timer.update_last_status() if before.channel and (timer := Timer.fetch_timer(before.channel.id)): - timer.last_seen.pop(member.id) + timer.last_seen.pop(member.id, None) await timer.update_last_status() diff --git a/bot/modules/study/timers/commands.py b/bot/modules/study/timers/commands.py index 46ad0eb5..39cbf68f 100644 --- a/bot/modules/study/timers/commands.py +++ b/bot/modules/study/timers/commands.py @@ -172,7 +172,7 @@ async def _pomo_admin(ctx, flags): splits = ctx.args.split(maxsplit=1) assume_channel = not (',' in splits[0]) assume_channel = assume_channel and not (channel and len(splits[0]) < 5) - assume_channel = assume_channel and (splits[0].strip('#<>').isdigit() or len(splits[0]) > 10) + assume_channel = assume_channel or (splits[0].strip('#<>').isdigit() and len(splits[0]) > 10) if assume_channel: # Assume first argument is a channel specifier channel = await ctx.find_channel( @@ -269,7 +269,7 @@ async def _pomo_admin(ctx, flags): ) if e.msg: usage.description = e.msg - return ctx.reply(embed=usage) + return await ctx.reply(embed=usage) # Input validation complete, assign values focus_length = int(timesplits[0]) @@ -282,7 +282,7 @@ async def _pomo_admin(ctx, flags): # First check number of timers timers = Timer.fetch_guild_timers(ctx.guild.id) if len(timers) >= MAX_TIMERS_PER_GUILD: - return ctx.error_reply( + return await ctx.error_reply( "Cannot create another timer!\n" "This server already has the maximum of `{}` timers.".format(MAX_TIMERS_PER_GUILD) )