From d2997e92ecd911a8761ecc57cf23dacf61be85af Mon Sep 17 00:00:00 2001 From: Bugsy <124417333+bugsbirb@users.noreply.github.com> Date: Sun, 9 Feb 2025 10:35:40 +0000 Subject: [PATCH] Update api.py --- utils/api.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/utils/api.py b/utils/api.py index 36492e9..c19dc73 100644 --- a/utils/api.py +++ b/utils/api.py @@ -93,6 +93,18 @@ def __init__(self, client: discord.Client): methods=[i.split("_")[0].upper()], ) + async def GET_shards(self): + shards = [] + for shard_id, shard_instance in self.client.shards.items(): + shard_info = f"{shard_instance.latency * 1000:.0f} ms" + guild_count = sum( + 1 for guild in self.client.guilds if guild.shard_id == shard_id + ) + shards.append( + {"id": shard_id, "latency": shard_info, "guilds": guild_count} + ) + return shards + async def GET_transcript(self, id: str): Result = await db["Tickets"].find_one({"_id": id}) if not Result: @@ -105,13 +117,13 @@ async def GET_transcript(self, id: str): async def GET_stats(self): return { "guilds": len(self.client.guilds), - "users": await self.get_total_users() - + "users": await self.get_total_users(), } - + async def get_total_users(self): total_members = sum(guild.member_count for guild in self.client.guilds) return total_members + async def GET_infraction(self, auth: str, server: int, id: str): if not await RestrictedValidation(auth): raise HTTPException( @@ -758,7 +770,6 @@ async def generate( ) await ctx.send( f"{tick} **{ctx.author.display_name}**, I've sent your API key to your/their DMs.", - ephemeral=True, )