"""Return the number of Discord guilds the bot is currently in."""
from __future__ import annotations
import json
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from tool_context import ToolContext
TOOL_NAME = "get_current_guild_count"
TOOL_DESCRIPTION = "Return the count of Discord guilds (servers) the bot is currently a member of."
TOOL_PARAMETERS = {
"type": "object",
"properties": {},
}
[docs]
async def run(ctx: ToolContext | None = None) -> str:
"""Execute this tool and return the result.
Args:
ctx (ToolContext | None): Tool execution context providing access to bot internals.
Returns:
str: Result string.
"""
from tools._discord_helpers import require_discord_client
client = require_discord_client(ctx)
if isinstance(client, str):
return client
return json.dumps({"guild_count": len(client.guilds)})