list_guild_webhooks
Retrieve all webhooks configured in a Discord server by providing the guild ID to manage integrations and automated messaging.
Instructions
List all webhooks in a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) |
Implementation Reference
- src/tools/webhook-tools.ts:70-92 (handler)Handler function that fetches all webhooks from the Discord guild using guild.fetchWebhooks() and formats the response, wrapped in error handling.async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const webhooks = await guild.fetchWebhooks(); return webhooks.map((wh) => ({ id: wh.id, name: wh.name, type: wh.type, channelId: wh.channelId, avatar: wh.avatar, owner: wh.owner ? { id: wh.owner.id, username: wh.owner.username } : null, createdAt: wh.createdAt?.toISOString(), })); }); 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/webhook-tools.ts:67-69 (schema)Input schema defining the required guildId parameter using Zod.{ guildId: z.string().describe('The ID of the server (guild)'), },
- src/tools/webhook-tools.ts:64-93 (registration)Registration of the list_guild_webhooks tool using server.tool(), including name, description, input schema, and handler.server.tool( 'list_guild_webhooks', 'List all webhooks 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 webhooks = await guild.fetchWebhooks(); return webhooks.map((wh) => ({ id: wh.id, name: wh.name, type: wh.type, channelId: wh.channelId, avatar: wh.avatar, owner: wh.owner ? { id: wh.owner.id, username: wh.owner.username } : null, createdAt: wh.createdAt?.toISOString(), })); }); 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:60-60 (registration)Invocation of registerWebhookTools which registers the webhook tools including list_guild_webhooks.registerWebhookTools(server);