From 7b76bc10e0436063e4368bf95093fdef73e60086 Mon Sep 17 00:00:00 2001 From: Ianardo DiCaprio <43935737+Ianardo-DiCaprio@users.noreply.github.com> Date: Fri, 16 Aug 2019 13:44:41 +0100 Subject: [PATCH] [Timerole] There was 2 issues with the check_day def (#67) * Update ccrole.py * listener * Update qrinvite.py * Update qrinvite.py * Make default enabled False Made default enabled False, this is because with a decent amount of users this skyrockets your CPU, so making this default off, only servers that actually want it will be enabled, thus reducing CPU usage. * Update dad.py * Add optional bot count and online count * Update timerole.py * Update timerole.py * Update timerole.py * Update timerole.py * Update timerole.py --- timerole/timerole.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) 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)