1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

re-count guilds on stats cog reload

This commit is contained in:
io 2020-07-16 23:23:58 +00:00
parent 78c671ed02
commit 379a3849f8

View file

@ -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