From 379a3849f8ab203fd0749ef629cdd0f585fd63c0 Mon Sep 17 00:00:00 2001 From: io Date: Thu, 16 Jul 2020 23:23:58 +0000 Subject: [PATCH] re-count guilds on stats cog reload --- cogs/stats.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cogs/stats.py b/cogs/stats.py index 8105c58..02a063b 100644 --- a/cogs/stats.py +++ b/cogs/stats.py @@ -24,6 +24,7 @@ class Stats(BotBinStats): seq = [0] * self.bot.shard_count if self.is_opener() else None # Use our user ID as part of the shm name to allow running multiple instances of the bot on the same machine. self.shlist = ShareableList(seq, name=f'emote-manager-{self.bot.user_id}') + self.count() def is_opener(self): """return whether this is the process that should open the shared memory""" @@ -40,15 +41,17 @@ class Stats(BotBinStats): @commands.Cog.listener() async def on_ready(self): + self.count() + if self.is_reporter(): + await self.send() + + def count(self): for shard_id in self.bot.shard_ids: self.shlist[shard_id] = 0 for guild in self.bot.guilds: self.shlist[guild.shard_id] += 1 - if self.is_reporter(): - await self.send() - @commands.Cog.listener() async def on_guild_join(self, guild): self.shlist[guild.shard_id] += 1