Add Discord sharding support and related configurations
Enhance the bot's architecture by introducing sharding capabilities, allowing for better scalability and performance. Update environment files to include sharding options, and modify the bot's core logic to handle shard connections and latencies. Implement shard-specific logging and API synchronization, ensuring that only the primary shard performs certain tasks. Update API schemas and routes to reflect shard information, improving the overall status reporting and monitoring of the bot's performance across multiple shards.
This commit is contained in:
@@ -28,13 +28,20 @@ async def get_status(bot: "Axiom" = Depends(get_bot)):
|
||||
"""
|
||||
Returns the live status of the bot.
|
||||
"""
|
||||
shard_ids = list(bot.shards.keys()) if bot.shards else ([0] if bot.shard_count else [])
|
||||
shard_latencies = [
|
||||
{"id": sid, "latency_ms": round(lat * 1000, 2)}
|
||||
for sid, lat in (bot.latencies or [])
|
||||
]
|
||||
return BotStatus(
|
||||
user=str(bot.user),
|
||||
id=str(bot.user.id) if bot.user else None,
|
||||
latency=bot.latency * 1000,
|
||||
guild_count=len(bot.guilds),
|
||||
user_count=sum(g.member_count or 0 for g in bot.guilds),
|
||||
shards=bot.shard_count
|
||||
shards=bot.shard_count,
|
||||
shard_ids=shard_ids,
|
||||
shard_latencies=shard_latencies,
|
||||
)
|
||||
|
||||
@router.get("/info", response_model=BotInfo, summary="Get bot info", description="Returns general information about the bot including command count and user reach.")
|
||||
|
||||
Reference in New Issue
Block a user