discord_send_webhook_message
Send messages to Discord channels using webhooks for automated notifications and bot integration.
Instructions
Sends a message to a Discord channel using a webhook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhookId | Yes | ||
| webhookToken | Yes | ||
| content | Yes | ||
| username | No | ||
| avatarURL | No | ||
| threadId | No |
Implementation Reference
- src/index.ts:1267-1305 (handler)Handler function in the tool execution switch statement. Parses arguments with Zod schema, fetches Discord webhook using client.fetchWebhook, sends message via webhook.send with provided parameters, handles errors and client readiness.case "discord_send_webhook_message": { const { webhookId, webhookToken, content, username, avatarURL, threadId } = SendWebhookMessageSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }], isError: true }; } const webhook = await client.fetchWebhook(webhookId, webhookToken); if (!webhook) { return { content: [{ type: "text", text: `Cannot find webhook with ID: ${webhookId}` }], isError: true }; } // Send the message await webhook.send({ content: content, username: username, avatarURL: avatarURL, threadId: threadId }); return { content: [{ type: "text", text: `Successfully sent webhook message to webhook ID: ${webhookId}` }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to send webhook message: ${error}` }], isError: true }; } }
- src/index.ts:128-135 (schema)Zod input schema for validating tool arguments: requires webhookId, webhookToken, content; optional username, avatarURL, threadId.const SendWebhookMessageSchema = z.object({ webhookId: z.string(), webhookToken: z.string(), content: z.string(), username: z.string().optional(), avatarURL: z.string().optional(), threadId: z.string().optional() });
- src/index.ts:414-428 (registration)Tool registration object in the ListTools handler's tools array, defining name, description, and JSON input schema matching the Zod schema.name: "discord_send_webhook_message", description: "Sends a message to a Discord channel using a webhook", inputSchema: { type: "object", properties: { webhookId: { type: "string" }, webhookToken: { type: "string" }, content: { type: "string" }, username: { type: "string" }, avatarURL: { type: "string" }, threadId: { type: "string" } }, required: ["webhookId", "webhookToken", "content"] } },