Skip to main content
Glama

discord_remove_reaction

Remove a specific emoji reaction from a Discord message by specifying the channel ID, message ID, and emoji. Simplify moderation and user interaction management.

Instructions

Removes a specific emoji reaction from a Discord message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
emojiYes
messageIdYes
userIdNo

Implementation Reference

  • The core handler function that executes the discord_remove_reaction tool. It fetches the channel and message, locates the specific reaction, and removes it either for a given userId or the bot itself using Discord.js API.
    export async function removeReactionHandler(
      args: unknown, 
      context: ToolContext
    ): Promise<ToolResponse> {
      const { channelId, messageId, emoji, userId } = RemoveReactionSchema.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 || !channel.isTextBased() || !('messages' in channel)) {
          return {
            content: [{ type: "text", text: `Cannot find text channel with ID: ${channelId}` }],
            isError: true
          };
        }
    
        const message = await channel.messages.fetch(messageId);
        if (!message) {
          return {
            content: [{ type: "text", text: `Cannot find message with ID: ${messageId}` }],
            isError: true
          };
        }
    
        // Get the reactions
        const reactions = message.reactions.cache;
        
        // Find the specific reaction
        const reaction = reactions.find(r => r.emoji.toString() === emoji || r.emoji.name === emoji);
        
        if (!reaction) {
          return {
            content: [{ type: "text", text: `Reaction ${emoji} not found on message ID: ${messageId}` }],
            isError: true
          };
        }
        
        if (userId) {
          // Remove a specific user's reaction
          await reaction.users.remove(userId);
          return {
            content: [{ 
              type: "text", 
              text: `Successfully removed reaction ${emoji} from user ID: ${userId} on message ID: ${messageId}` 
            }]
          };
        } else {
          // Remove bot's reaction
          await reaction.users.remove(context.client.user.id);
          return {
            content: [{ 
              type: "text", 
              text: `Successfully removed bot's reaction ${emoji} from message ID: ${messageId}` 
            }]
          };
        }
      } catch (error) {
        return handleDiscordError(error);
      }
    }
  • MCP tool schema definition including name, description, and input schema with required parameters: channelId, messageId, emoji; optional: userId.
    {
      name: "discord_remove_reaction",
      description: "Removes a specific emoji reaction from a Discord message",
      inputSchema: {
        type: "object",
        properties: {
          channelId: { type: "string" },
          messageId: { type: "string" },
          emoji: { type: "string" },
          userId: { type: "string" }
        },
        required: ["channelId", "messageId", "emoji"]
      }
    },
  • src/server.ts:153-156 (registration)
    Registers the tool handler in the MCP server's switch statement for call_tool requests, dispatching to removeReactionHandler.
    case "discord_remove_reaction":
      this.logClientState("before discord_remove_reaction handler");
      toolResponse = await removeReactionHandler(args, this.toolContext);
      return toolResponse;
  • Re-exports the removeReactionHandler from reactions.ts for use in the main server imports (captures import and export lines).
      addReactionHandler,
      addMultipleReactionsHandler,
      removeReactionHandler,
      deleteMessageHandler
    } from './reactions.js';
    import {
      createWebhookHandler,
      sendWebhookMessageHandler,
      editWebhookHandler,
      deleteWebhookHandler
    } from './webhooks.js';
    
    // Export tool handlers
    export {
      loginHandler,
      sendMessageHandler,
      getForumChannelsHandler,
      createForumPostHandler,
      getForumPostHandler,
      replyToForumHandler,
      deleteForumPostHandler,
      createTextChannelHandler,
      deleteChannelHandler,
      readMessagesHandler,
      getServerInfoHandler,
      addReactionHandler,
      addMultipleReactionsHandler,
      removeReactionHandler,
  • Imports the Zod validation schema RemoveReactionSchema used for parsing tool arguments in the handler.
    import { 
      AddReactionSchema, 
      AddMultipleReactionsSchema, 
      RemoveReactionSchema,
      DeleteMessageSchema

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

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