Skip to main content
Glama

add_reaction

Add an emoji reaction to a Discord message by specifying server, channel, message, and emoji identifiers.

Instructions

Add a reaction to a message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
messageIdYesThe ID of the message
emojiYesThe emoji to react with (unicode or custom emoji ID)

Implementation Reference

  • The handler function for the 'add_reaction' tool. Fetches the Discord guild, channel, and message, then adds the specified emoji reaction to the message using message.react(). Wraps in error handling and returns formatted response.
    async ({ guildId, channelId, messageId, emoji }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!isMessageableChannel(channel)) { throw new Error('Channel does not support messages'); } const message = await channel.messages.fetch(messageId); await message.react(emoji); return { messageId, emoji, message: 'Reaction added successfully' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Input schema for the 'add_reaction' tool using Zod validation. Defines required string parameters: guildId, channelId, messageId, and emoji.
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), messageId: z.string().describe('The ID of the message'), emoji: z.string().describe('The emoji to react with (unicode or custom emoji ID)'), },
  • Direct registration of the 'add_reaction' tool using server.tool(), including name, description, input schema, and handler function within registerMessageTools.
    server.tool( 'add_reaction', 'Add a reaction to a message', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), messageId: z.string().describe('The ID of the message'), emoji: z.string().describe('The emoji to react with (unicode or custom emoji ID)'), }, async ({ guildId, channelId, messageId, emoji }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!isMessageableChannel(channel)) { throw new Error('Channel does not support messages'); } const message = await channel.messages.fetch(messageId); await message.react(emoji); return { messageId, emoji, message: 'Reaction added successfully' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • src/index.ts:58-58 (registration)
    Top-level call to registerMessageTools(server) in createMcpServer(), which registers the add_reaction tool among others.
    registerMessageTools(server);
  • Helper function used by the handler to validate if a channel supports messages (TextChannel, NewsChannel, ThreadChannel).
    function isMessageableChannel(channel: unknown): channel is MessageableChannel { if (!channel || typeof channel !== 'object') return false; const ch = channel as { type?: number }; return ch.type === ChannelType.GuildText || ch.type === ChannelType.GuildAnnouncement || ch.type === ChannelType.PublicThread || ch.type === ChannelType.PrivateThread || ch.type === ChannelType.AnnouncementThread; }

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

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