Skip to main content
Glama

list_bans

Retrieve a list of banned users from a Discord server to review moderation actions and manage server security.

Instructions

List banned users for the server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_idNo
limitNo

Implementation Reference

  • The handler function for the 'list_bans' tool. It resolves the guild, fetches banned users using guild.bans(), limits the results, and returns a formatted text list including user display name, ID, and ban reason.
    async def list_bans( server_id: str | int | None = None, limit: int = 20, ctx: Context = None, ) -> str: # type: ignore[override] """List banned users for the server.""" assert ctx is not None bot, config = await _acquire(ctx) guild_id = _resolve_guild_id(config, server_id) guild = await _ensure_guild(bot, guild_id) limit = max(1, min(limit, 100)) entries: list[discord.guild.BanEntry] = [] try: async for entry in guild.bans(limit=None): entries.append(entry) if len(entries) >= limit: break except discord.DiscordException as exc: raise _describe_discord_error("list bans", exc) from exc if not entries: return f"No banned users found for {guild.name}." lines = [f"**Banned users for {guild.name} (showing {len(entries)}):**"] for entry in entries: user = entry.user reason_text = entry.reason or "No reason provided" lines.append(f"• {user.display_name} ({user.id}) – Reason: {reason_text}") return "\n".join(lines)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wowjinxy/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server