discord_remove_reaction
Remove a specific emoji reaction from a Discord message by specifying the channel ID, message ID, and emoji. Simplify moderation and user interaction management.
Instructions
Removes a specific emoji reaction from a Discord message
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| emoji | Yes | ||
| messageId | Yes | ||
| userId | No |
Input Schema (JSON Schema)
{
"properties": {
"channelId": {
"type": "string"
},
"emoji": {
"type": "string"
},
"messageId": {
"type": "string"
},
"userId": {
"type": "string"
}
},
"required": [
"channelId",
"messageId",
"emoji"
],
"type": "object"
}
Implementation Reference
- src/tools/reactions.ts:104-168 (handler)The core handler function that executes the discord_remove_reaction tool. It fetches the channel and message, locates the specific reaction, and removes it either for a given userId or the bot itself using Discord.js API.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 || !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}` }] }; } else { // 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); } }
- src/toolList.ts:199-212 (schema)MCP tool schema definition including name, description, and input schema with required parameters: channelId, messageId, emoji; optional: userId.{ 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:153-156 (registration)Registers the tool handler in the MCP server's switch statement for call_tool requests, dispatching to removeReactionHandler.case "discord_remove_reaction": this.logClientState("before discord_remove_reaction handler"); toolResponse = await removeReactionHandler(args, this.toolContext); return toolResponse;
- src/tools/tools.ts:27-54 (registration)Re-exports the removeReactionHandler from reactions.ts for use in the main server imports (captures import and export lines).addReactionHandler, addMultipleReactionsHandler, removeReactionHandler, deleteMessageHandler } from './reactions.js'; import { createWebhookHandler, sendWebhookMessageHandler, editWebhookHandler, deleteWebhookHandler } from './webhooks.js'; // Export tool handlers export { loginHandler, sendMessageHandler, getForumChannelsHandler, createForumPostHandler, getForumPostHandler, replyToForumHandler, deleteForumPostHandler, createTextChannelHandler, deleteChannelHandler, readMessagesHandler, getServerInfoHandler, addReactionHandler, addMultipleReactionsHandler, removeReactionHandler,
- src/tools/reactions.ts:3-7 (helper)Imports the Zod validation schema RemoveReactionSchema used for parsing tool arguments in the handler.import { AddReactionSchema, AddMultipleReactionsSchema, RemoveReactionSchema, DeleteMessageSchema