discord_delete_message
Delete a specific message from a Discord text channel using channel and message IDs. This tool removes unwanted or incorrect messages to maintain channel organization.
Instructions
Deletes a specific message from a Discord text channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| messageId | Yes | ||
| reason | No |
Implementation Reference
- src/index.ts:1176-1218 (handler)The handler implementation for the discord_delete_message tool. It validates input with DeleteMessageSchema, checks client readiness, fetches the channel and message, deletes the message, and returns success or error response.case "discord_delete_message": { const { channelId, messageId, reason } = DeleteMessageSchema.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 channel = await client.channels.fetch(channelId); if (!channel || !channel.isTextBased() || !('messages' in channel)) { return { content: [{ type: "text", text: `Cannot find text channel with ID: ${channelId}` }], isError: true }; } // Fetch the message const message = await channel.messages.fetch(messageId); if (!message) { return { content: [{ type: "text", text: `Cannot find message with ID: ${messageId}` }], isError: true }; } // Delete the message await message.delete(); return { content: [{ type: "text", text: `Successfully deleted message with ID: ${messageId} from channel: ${channelId}` }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to delete message: ${error}` }], isError: true }; } }
- src/index.ts:115-119 (schema)Zod schema defining the input parameters for the discord_delete_message tool: channelId, messageId, and optional reason.const DeleteMessageSchema = z.object({ channelId: z.string(), messageId: z.string(), reason: z.string().optional() });
- src/index.ts:386-398 (registration)Registration of the discord_delete_message tool in the list of available tools, including name, description, and input schema.{ name: "discord_delete_message", description: "Deletes a specific message from a Discord text channel", inputSchema: { type: "object", properties: { channelId: { type: "string" }, messageId: { type: "string" }, reason: { type: "string" } }, required: ["channelId", "messageId"] } },