From 25119e49f2e7a928b530aada6b95ee8de06b3bd8 Mon Sep 17 00:00:00 2001 From: io Date: Thu, 3 Jun 2021 08:30:26 +0000 Subject: [PATCH] update guild count live --- bot.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bot.py b/bot.py index 27f6f15..f2c59d2 100755 --- a/bot.py +++ b/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