discord_delete_webhook
Remove an existing Discord webhook by specifying its ID and token. This tool ensures unwanted or outdated webhooks are deleted from your Discord channel efficiently.
Instructions
Deletes an existing webhook for a Discord channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| reason | No | ||
| webhookId | Yes | ||
| webhookToken | No |
Implementation Reference
- src/tools/webhooks.ts:142-175 (handler)The core handler function that validates input with DeleteWebhookSchema, fetches the webhook using Discord client, and deletes it with optional reason.export async function deleteWebhookHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { webhookId, webhookToken, reason } = DeleteWebhookSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in." }], isError: true }; } const webhook = await context.client.fetchWebhook(webhookId, webhookToken); if (!webhook) { return { content: [{ type: "text", text: `Cannot find webhook with ID: ${webhookId}` }], isError: true }; } // Delete the webhook await webhook.delete(reason || "Webhook deleted via API"); return { content: [{ type: "text", text: `Successfully deleted webhook with ID: ${webhook.id}` }] }; } catch (error) { return handleDiscordError(error); } }
- src/schemas.ts:129-133 (schema)Zod schema for validating the tool inputs: webhookId (required), optional webhookToken and reason.export const DeleteWebhookSchema = z.object({ webhookId: z.string(), webhookToken: z.string().optional(), reason: z.string().optional() });
- src/server.ts:178-181 (registration)Server dispatch switch case that invokes the deleteWebhookHandler with parsed args and tool context.case "discord_delete_webhook": this.logClientState("before discord_delete_webhook handler"); toolResponse = await deleteWebhookHandler(args, this.toolContext); return toolResponse;
- src/toolList.ts:284-296 (registration)MCP tool list entry defining the tool name, description, and JSON schema for input validation.{ name: "discord_delete_webhook", description: "Deletes an existing webhook for a Discord channel", inputSchema: { type: "object", properties: { webhookId: { type: "string" }, webhookToken: { type: "string" }, reason: { type: "string" } }, required: ["webhookId"] } },