From 42e47bea1a2606ee4ee0f1f89ba292c2d5ea6621 Mon Sep 17 00:00:00 2001 From: Conatum Date: Wed, 20 Oct 2021 12:55:36 +0300 Subject: [PATCH] fix (rooms): Cancel rooms on system shutdown. Fix typos in the `success_response` for `accountability_category`. Make the `TimeSlot.cancel()` method more robust. --- bot/modules/accountability/TimeSlot.py | 3 ++- bot/modules/accountability/admin.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bot/modules/accountability/TimeSlot.py b/bot/modules/accountability/TimeSlot.py index b87a0df3..ac12efea 100644 --- a/bot/modules/accountability/TimeSlot.py +++ b/bot/modules/accountability/TimeSlot.py @@ -409,12 +409,13 @@ class TimeSlot: if self.channel: try: await self.channel.delete() + self.channel = None except discord.HTTPException: pass if self.message: try: - timestamp = self.start_time.timestamp() + timestamp = int(self.start_time.timestamp()) embed = discord.Embed( title="Session - ".format( timestamp, timestamp + 3600 diff --git a/bot/modules/accountability/admin.py b/bot/modules/accountability/admin.py index cc1bd9d2..e294feef 100644 --- a/bot/modules/accountability/admin.py +++ b/bot/modules/accountability/admin.py @@ -1,3 +1,4 @@ +import asyncio import discord import settings @@ -37,12 +38,12 @@ class accountability_category(settings.Channel, settings.GuildSetting): return "The accountability system has been started in **{}**.".format(self.value.name) else: if self.id in AG.cache: - aguild = AG.cache[self.id] + aguild = AG.cache.pop(self.id) if aguild.current_slot: - aguild.current_lost.cancel() + asyncio.create_task(aguild.current_slot.cancel()) if aguild.upcoming_slot: - aguild.upcoming_slot.cancel() - return "The accountability system has been stopped." + asyncio.create_task(aguild.upcoming_slot.cancel()) + return "The accountability system has been shut down." else: return "The accountability category has been unset."