Skip to main content
Glama
drvova

Discord MCP Server

discord_edit_message

Edit existing Discord messages by providing channel ID, message ID, and new content to update text in Discord channels.

Instructions

Edit a previously sent message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYesThe Discord channel ID
messageIdYesThe message ID to edit
contentYesNew message content

Implementation Reference

  • The core handler function for the 'discord_edit_message' tool. It validates the input parameters using the EditMessageSchema and delegates the actual Discord API call to DiscordService.editMessage.
    async editMessage(channelId: string, messageId: string, newMessage: string): Promise<string> {
      const parsed = schemas.EditMessageSchema.parse({ channelId, messageId, newMessage });
      return await this.discordService.editMessage(parsed.channelId, parsed.messageId, parsed.newMessage);
    }
  • Zod schema that defines and validates the input parameters for the 'discord_edit_message' tool: channelId, messageId, newMessage.
    export const EditMessageSchema = z.object({
      channelId: z.string().describe("Discord channel ID"),
      messageId: z.string().describe("Specific message ID"),
      newMessage: z.string().describe("New message content")
    });
  • Dynamic registration/dispatch mechanism that converts snake_case action names (e.g., 'edit_message' or 'discord_edit_message') to camelCase method names on AutomationManager and invokes them.
    private async callAutomationMethod(action: string, params: any): Promise<string> {
      // Convert action name to method name (snake_case to camelCase)
      const methodName = action.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
      
      // Check if method exists
      if (typeof (this.automationManager as any)[methodName] === 'function') {
        // Call the method with params
        return await (this.automationManager as any)[methodName](...Object.values(params));
      }
      
      throw new Error(`Method '${methodName}' not found in AutomationManager`);
    }
  • Entry point for executing tools/actions, including permission checks via ConfigManager, logging, rate limiting, and delegation to specific handlers via callAutomationMethod.
    async executeAction(action: string, params: any): Promise<string> {
      try {
        // Check if action is allowed
        if (!this.configManager.isActionAllowed(action)) {
          throw ErrorHandler.createPermissionError(`Action '${action}' is not allowed`);
        }
        
        // Log the operation
        this.logger.logOperation(action, params);
        
        // Wait for rate limits if needed
        if (this.configManager.getConfig().rateLimitProtection) {
          await this.rateLimiter.waitForRateLimit(action);
        }
        
        // Execute the action using reflection-like approach
        const result = await this.callAutomationMethod(action, params);
        
        this.logger.info(`Action '${action}' executed successfully`);
        return result;
      } catch (error) {
        this.logger.logError(`Action '${action}' failed`, error);
        ErrorHandler.handle(error);
      }
    }

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/drvova/discord-mcp'

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