diff --git a/timerole/timerole.py b/timerole/timerole.py index dfc51a1..44dd767 100644 --- a/timerole/timerole.py +++ b/timerole/timerole.py @@ -21,6 +21,10 @@ class Timerole(Cog): self.config.register_global(**default_global) self.config.register_guild(**default_guild) + self.updating = self.bot.loop.create_task(self.check_day()) + + def cog_unload(self): + self.updating.cancel() @commands.command() @checks.guildowner() @@ -193,19 +197,5 @@ class Timerole(Cog): async def check_day(self): while self is self.bot.get_cog("Timerole"): - tomorrow = datetime.now() + timedelta(days=1) - midnight = datetime( - year=tomorrow.year, - month=tomorrow.month, - day=tomorrow.day, - hour=0, - minute=0, - second=0, - ) - - await asyncio.sleep((midnight - datetime.now()).seconds) - await self.timerole_update() - - await asyncio.sleep(3) - # then start loop over again + await asyncio.sleep(86400)