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
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) |
Implementation Reference
- src/tools/member-tools.ts:242-260 (handler)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) }] }; }
- src/tools/member-tools.ts:239-241 (schema)Input schema for list_bans tool using Zod: requires guildId string.{ guildId: z.string().describe('The ID of the server (guild)'), },
- src/tools/member-tools.ts:236-261 (registration)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);