Skip to content

Commit

Permalink
Update api.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Feb 9, 2025
1 parent 279a027 commit d2997e9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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,
)

Expand Down

0 comments on commit d2997e9

Please sign in to comment.