Skip to main content
Glama
jar285

MCP-Discord

by jar285

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
NameRequiredDescriptionDefault
channelIdYes
messageIdYes
reasonNo

Implementation Reference

  • 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 }; } }
  • 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"] } },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jar285/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server