Skip to main content
Glama

list_bans

Retrieve a list of all banned users from a Discord server by providing the server ID. This tool helps server administrators view and manage bans effectively.

Instructions

List all banned users in a server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)

Implementation Reference

  • Handler function for list_bans tool: fetches bans from Discord guild using client.guilds.fetch(guildId).bans.fetch(), maps to {userId, username, reason}, wraps in error handling and JSON response.
    async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const bans = await guild.bans.fetch(); return bans.map((ban) => ({ userId: ban.user.id, username: ban.user.username, reason: ban.reason, })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Input schema for list_bans tool using Zod: requires guildId string.
    { guildId: z.string().describe('The ID of the server (guild)'), },
  • Registers the list_bans tool using server.tool() with name, description, input schema, and handler function inside registerMemberTools.
    server.tool( 'list_bans', 'List all banned users in a server', { guildId: z.string().describe('The ID of the server (guild)'), }, async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const bans = await guild.bans.fetch(); return bans.map((ban) => ({ userId: ban.user.id, username: ban.user.username, reason: ban.reason, })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • src/index.ts:55-55 (registration)
    Calls registerMemberTools(server) in createMcpServer() to register all member tools including list_bans.
    registerMemberTools(server);

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/scarecr0w12/discord-mcp'

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