discord_edit_webhook
Modifies an existing Discord webhook to update its name, avatar, or channel ID. Enables precise control over webhook configurations for enhanced interaction management.
Instructions
Edits an existing webhook for a Discord channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| avatar | No | ||
| channelId | No | ||
| name | No | ||
| reason | No | ||
| webhookId | Yes | ||
| webhookToken | No |
Implementation Reference
- src/tools/webhooks.ts:101-139 (handler)The main execution handler for the 'discord_edit_webhook' tool. Validates input arguments using EditWebhookSchema, fetches the webhook from Discord API, edits it with provided name, avatar, channel, or reason, and returns success or error response.export async function editWebhookHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { webhookId, webhookToken, name, avatar, channelId, reason } = EditWebhookSchema.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 }; } // Edit the webhook await webhook.edit({ name: name, avatar: avatar, channel: channelId, reason: reason }); return { content: [{ type: "text", text: `Successfully edited webhook with ID: ${webhook.id}` }] }; } catch (error) { return handleDiscordError(error); } }
- src/schemas.ts:120-127 (schema)Zod schema for input validation used in the editWebhookHandler to parse and validate arguments like webhookId, name, avatar, etc.export const EditWebhookSchema = z.object({ webhookId: z.string(), webhookToken: z.string().optional(), name: z.string().optional(), avatar: z.string().optional(), channelId: z.string().optional(), reason: z.string().optional() });
- src/toolList.ts:269-282 (schema)JSON schema definition for the 'discord_edit_webhook' tool used for MCP tool registration, defining input properties and requirements.name: "discord_edit_webhook", description: "Edits an existing webhook for a Discord channel", inputSchema: { type: "object", properties: { webhookId: { type: "string" }, webhookToken: { type: "string" }, name: { type: "string" }, avatar: { type: "string" }, channelId: { type: "string" }, reason: { type: "string" } }, required: ["webhookId"] }
- src/server.ts:173-176 (registration)Dispatch registration in the server tool execution switch statement that calls editWebhookHandler when the tool name matches 'discord_edit_webhook'.case "discord_edit_webhook": this.logClientState("before discord_edit_webhook handler"); toolResponse = await editWebhookHandler(args, this.toolContext); return toolResponse;