Skip to main content
Glama

discord_remove_reaction

Remove a specific emoji reaction from a Discord message by providing the channel ID, message ID, and emoji identifier. This tool helps manage reactions in Discord conversations.

Instructions

Removes a specific emoji reaction from a Discord message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
messageIdYes
emojiYes
userIdNo

Implementation Reference

  • The main execution handler for the 'discord_remove_reaction' tool. Parses input arguments using RemoveReactionSchema, fetches the channel and message, locates the specific reaction, and removes it either for a specified user or the bot itself. Handles errors with handleDiscordError.
    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?.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}`,
              },
            ],
          };
        }
        // 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 definition including name, description, and input schema for 'discord_remove_reaction'.
    {
      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:176-179 (registration)
    Registers and dispatches to the removeReactionHandler in the MCP server's CallToolRequest handler switch statement.
    case 'discord_remove_reaction':
      this.logClientState('before discord_remove_reaction handler');
      toolResponse = await removeReactionHandler(args, this.toolContext);
      return toolResponse;
  • Zod schema for runtime input validation used by the removeReactionHandler.
    export const RemoveReactionSchema = z.object({
      channelId: z.string(),
      messageId: z.string(),
      emoji: z.string(),
      userId: z.string().optional(),
    });
  • Re-exports the removeReactionHandler from reactions.ts for convenient import in server.ts.
    removeReactionHandler,

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

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