remove_reactions
Remove reactions from Discord messages by specifying server, channel, and message IDs. Optionally target specific emojis or users to clean up message interactions.
Instructions
Remove reactions from a message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| channelId | Yes | The ID of the channel | |
| messageId | Yes | The ID of the message | |
| emoji | No | Specific emoji to remove (removes all if not specified) | |
| userId | No | Remove reaction from specific user |
Implementation Reference
- src/tools/message-tools.ts:363-394 (handler)Handler function that fetches the Discord message and removes reactions: all reactions if no emoji, specific emoji from all users, or specific user's reaction on emoji using Discord.js reactions API. Wraps in error handling and returns formatted response.async ({ guildId, channelId, messageId, emoji, userId }) => { 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); if (!emoji) { await message.reactions.removeAll(); return { messageId, message: 'All reactions removed' }; } else if (userId) { const reaction = message.reactions.cache.get(emoji); if (reaction) await reaction.users.remove(userId); return { messageId, emoji, userId, message: 'User reaction removed' }; } else { const reaction = message.reactions.cache.get(emoji); if (reaction) await reaction.remove(); return { messageId, emoji, message: 'Reaction removed' }; } }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
- src/tools/message-tools.ts:356-362 (schema)Zod input schema validating guildId, channelId, messageId (required), and optional emoji and userId parameters.{ 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().optional().describe('Specific emoji to remove (removes all if not specified)'), userId: z.string().optional().describe('Remove reaction from specific user'), },
- src/tools/message-tools.ts:352-395 (registration)MCP server.tool registration for 'remove_reactions' tool, specifying name, description, input schema, and handler function.// Remove reactions server.tool( 'remove_reactions', 'Remove reactions from 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().optional().describe('Specific emoji to remove (removes all if not specified)'), userId: z.string().optional().describe('Remove reaction from specific user'), }, async ({ guildId, channelId, messageId, emoji, userId }) => { 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); if (!emoji) { await message.reactions.removeAll(); return { messageId, message: 'All reactions removed' }; } else if (userId) { const reaction = message.reactions.cache.get(emoji); if (reaction) await reaction.users.remove(userId); return { messageId, emoji, userId, message: 'User reaction removed' }; } else { const reaction = message.reactions.cache.get(emoji); if (reaction) await reaction.remove(); return { messageId, emoji, message: 'Reaction removed' }; } }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );