discord_delete_message
Delete specific messages from a Discord text channel by providing the channel ID and message ID, ensuring precise message management and moderation.
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)Handler for the 'discord_delete_message' tool. Validates arguments with DeleteMessageSchema, checks client readiness, fetches the specified channel and message, deletes the message, and returns appropriate success or error responses.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 (string), messageId (string), and optional reason (string).const DeleteMessageSchema = z.object({ channelId: z.string(), messageId: z.string(), reason: z.string().optional() });
- src/index.ts:386-398 (registration)Tool registration in the listTools response, including name, description, and inputSchema matching the DeleteMessageSchema.{ 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"] } },