mirror of
https://github.com/uhIgnacio/EmoteManager.git
synced 2024-08-15 02:23:13 +00:00
update guild count live
This commit is contained in:
parent
5054a8f68f
commit
25119e49f2
1 changed files with 18 additions and 0 deletions
18
bot.py
18
bot.py
|
@ -91,6 +91,24 @@ class Bot(Bot):
|
|||
shard_id, guild_count, member_count,
|
||||
)
|
||||
|
||||
async def update_shard(self, guild):
|
||||
guilds = [guild2 for guild2 in self.guilds if guild2.shard_id == guild.shard_id]
|
||||
guild_count = len(guilds)
|
||||
member_count = sum(guild.member_count for guild in guilds)
|
||||
|
||||
await self.pool.execute(
|
||||
"""
|
||||
UPDATE shard_info
|
||||
SET
|
||||
guild_count = $2,
|
||||
member_count = $3
|
||||
WHERE shard_id = $1
|
||||
""",
|
||||
guild.shard_id, guild_count, member_count,
|
||||
)
|
||||
|
||||
on_guild_join = on_guild_remove = update_shard
|
||||
|
||||
def main():
|
||||
import sys
|
||||
|
||||
|
|
Loading…
Reference in a new issue