modify_webhook
Update Discord webhook properties including name, avatar, channel location, and modification reason for server management.
Instructions
Modify a webhook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhookId | Yes | The ID of the webhook | |
| name | No | New name for the webhook | |
| avatar | No | URL of the new avatar image | |
| channelId | No | Move webhook to different channel | |
| reason | No | Reason for modifying |
Implementation Reference
- src/tools/webhook-tools.ts:174-200 (handler)Executes the modify_webhook tool: fetches Discord webhook, conditionally builds edit data for name, avatar, channel, reason, edits via Discord.js webhook.edit(), handles errors with withErrorHandling, returns JSON response.async ({ webhookId, name, avatar, channelId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const webhook = await client.fetchWebhook(webhookId); const editData: { name?: string; avatar?: string; channel?: string; reason?: string } = {}; if (name) editData.name = name; if (avatar) editData.avatar = avatar; if (channelId) editData.channel = channelId; if (reason) editData.reason = reason; const updated = await webhook.edit(editData); return { id: updated.id, name: updated.name, channelId: updated.channelId, message: 'Webhook updated successfully', }; }); 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:167-173 (schema)Zod schema defining input parameters for modify_webhook tool: required webhookId, optional name, avatar, channelId, reason with descriptions.{ webhookId: z.string().describe('The ID of the webhook'), name: z.string().optional().describe('New name for the webhook'), avatar: z.string().optional().describe('URL of the new avatar image'), channelId: z.string().optional().describe('Move webhook to different channel'), reason: z.string().optional().describe('Reason for modifying'), },
- src/tools/webhook-tools.ts:164-201 (registration)Registers the modify_webhook tool on the MCP server with name, description, input schema, and handler function.server.tool( 'modify_webhook', 'Modify a webhook', { webhookId: z.string().describe('The ID of the webhook'), name: z.string().optional().describe('New name for the webhook'), avatar: z.string().optional().describe('URL of the new avatar image'), channelId: z.string().optional().describe('Move webhook to different channel'), reason: z.string().optional().describe('Reason for modifying'), }, async ({ webhookId, name, avatar, channelId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const webhook = await client.fetchWebhook(webhookId); const editData: { name?: string; avatar?: string; channel?: string; reason?: string } = {}; if (name) editData.name = name; if (avatar) editData.avatar = avatar; if (channelId) editData.channel = channelId; if (reason) editData.reason = reason; const updated = await webhook.edit(editData); return { id: updated.id, name: updated.name, channelId: updated.channelId, message: 'Webhook updated successfully', }; }); 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)Top-level registration call to registerWebhookTools which includes the modify_webhook tool among others.registerWebhookTools(server);
- src/index.ts:18-18 (registration)Import of registerWebhookTools function used to register webhook tools including modify_webhook.import { registerWebhookTools } from './tools/webhook-tools.js';