Skip to main content
Glama

discord_delete_message

Delete a specific message from a Discord text channel using channel ID, message ID, and an optional reason.

Instructions

Deletes a specific message from a Discord text channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
messageIdYes
reasonNo

Implementation Reference

  • The deleteMessageHandler function that executes the delete message logic. It parses args with DeleteMessageSchema, fetches the channel, fetches the message, and calls message.delete().
    // Delete message handler
    export async function deleteMessageHandler(
      args: unknown,
      context: ToolContext
    ): Promise<ToolResponse> {
      const { channelId, messageId } = DeleteMessageSchema.parse(args);
      try {
        if (!context.client.isReady()) {
          return {
            content: [{ type: 'text', text: 'Discord client not logged in.' }],
            isError: true,
          };
        }
    
        const channel = await context.client.channels.fetch(channelId);
        if (!(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 handleDiscordError(error);
      }
    }
  • DeleteMessageSchema - Zod schema defining the input validation for discord_delete_message tool: channelId (string), messageId (string), and optional reason (string).
    export const DeleteMessageSchema = z.object({
      channelId: z.string(),
      messageId: z.string(),
      reason: z.string().optional(),
    });
  • Registration entry in tool-list.ts for 'discord_delete_message' with name, description, and inputSchema (channelId, messageId, reason - channelId and messageId required).
    {
      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'],
      },
    },
  • src/server.ts:181-184 (registration)
    Case statement in server.ts that routes 'discord_delete_message' to the deleteMessageHandler function.
    case 'discord_delete_message':
      this.logClientState('before discord_delete_message handler');
      toolResponse = await deleteMessageHandler(args, this.toolContext);
      return toolResponse;
  • Case statement in transport.ts that routes 'discord_delete_message' to deleteMessageHandler.
    case 'discord_delete_message':
      result = await deleteMessageHandler(params, this.toolContext!);
      break;

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full responsibility for disclosing behavior. It only states the action ('Deletes') without mentioning irreversibility, permissions, error handling, or side effects. The agent is not informed that deletion is permanent or what happens if the message does not exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no wasted words. It is front-loaded with the verb and provides the essential information in a concise, well-structured format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple, but the description lacks necessary context for an agent to make a fully informed choice. It does not address alternative delete tools, behavioral implications, or parameter usage, leaving gaps that a richer description should fill.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It implies the need for channelId and messageId via 'text channel' and 'specific message', but does not explicitly name them or explain the optional 'reason' parameter. This adds minimal meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Deletes') and resource ('a specific message from a Discord text channel'), clearly distinguishing it from sibling delete tools for categories, channels, and forum posts. The purpose is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives, such as deleting an entire channel or a forum post. There is no mention of prerequisites, permissions, or exclusion conditions, leaving the agent to infer usage from context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.