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
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| messageId | Yes | ||
| emoji | Yes |
Implementation Reference
- src/tools/reactions.ts:11-61 (handler)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); } }
- src/tool-list.ts:174-186 (schema)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'], }, },
- src/schemas.ts:73-77 (schema)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;