Skip to main content
Glama

discord_add_reaction

Add emoji reactions to Discord messages using channel ID, message ID, and emoji identifier to express responses or interactions.

Instructions

Adds an emoji reaction to a specific Discord message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
messageIdYes
emojiYes

Implementation Reference

  • The main execution logic for the 'discord_add_reaction' tool. Parses input args with AddReactionSchema, checks client readiness, fetches the Discord channel and message, adds the reaction using message.react(emoji), and returns a success or error response.
    export async function addReactionHandler(
      args: unknown,
      context: ToolContext
    ): Promise<ToolResponse> {
      const { channelId, messageId, emoji } = AddReactionSchema.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,
          };
        }
    
        // Add the reaction
        await message.react(emoji);
    
        return {
          content: [
            {
              type: 'text',
              text: `Successfully added reaction ${emoji} to message ID: ${messageId}`,
            },
          ],
        };
      } catch (error) {
        return handleDiscordError(error);
      }
    }
  • MCP protocol tool registration including the name, description, and JSON schema for input validation (channelId, messageId, emoji).
    {
      name: 'discord_add_reaction',
      description: 'Adds an emoji reaction to a specific Discord message',
      inputSchema: {
        type: 'object',
        properties: {
          channelId: { type: 'string' },
          messageId: { type: 'string' },
          emoji: { type: 'string' },
        },
        required: ['channelId', 'messageId', 'emoji'],
      },
    },
  • Zod runtime validation schema (AddReactionSchema) used inside the handler to parse and validate arguments.
    export const AddReactionSchema = z.object({
      channelId: z.string(),
      messageId: z.string(),
      emoji: z.string(),
    });
  • src/server.ts:161-164 (registration)
    Server-side dispatch case that invokes the addReactionHandler upon receiving a 'discord_add_reaction' tool call.
    case 'discord_add_reaction':
      this.logClientState('before discord_add_reaction handler');
      toolResponse = await addReactionHandler(args, this.toolContext);
      return toolResponse;

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