re-count guilds on stats cog reload
This commit is contained in:
parent
78c671ed02
commit
379a3849f8
|
@ -24,6 +24,7 @@ class Stats(BotBinStats):
|
||||||
seq = [0] * self.bot.shard_count if self.is_opener() else None
|
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.
|
# 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.shlist = ShareableList(seq, name=f'emote-manager-{self.bot.user_id}')
|
||||||
|
self.count()
|
||||||
|
|
||||||
def is_opener(self):
|
def is_opener(self):
|
||||||
"""return whether this is the process that should open the shared memory"""
|
"""return whether this is the process that should open the shared memory"""
|
||||||
|
@ -40,15 +41,17 @@ class Stats(BotBinStats):
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_ready(self):
|
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:
|
for shard_id in self.bot.shard_ids:
|
||||||
self.shlist[shard_id] = 0
|
self.shlist[shard_id] = 0
|
||||||
|
|
||||||
for guild in self.bot.guilds:
|
for guild in self.bot.guilds:
|
||||||
self.shlist[guild.shard_id] += 1
|
self.shlist[guild.shard_id] += 1
|
||||||
|
|
||||||
if self.is_reporter():
|
|
||||||
await self.send()
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_guild_join(self, guild):
|
async def on_guild_join(self, guild):
|
||||||
self.shlist[guild.shard_id] += 1
|
self.shlist[guild.shard_id] += 1
|
||||||
|
|
Loading…
Reference in New Issue