Skip to main content
Glama
jar285

MCP-Discord

by jar285

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

Implementation Reference

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

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