modify_emoji
Change custom emoji names and permissions in Discord servers to manage emoji usage and organization.
Instructions
Modify a custom emoji in a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| emojiId | Yes | The ID of the emoji to modify | |
| name | No | New name for the emoji | |
| roles | No | Role IDs that can use this emoji | |
| reason | No | Reason for modifying the emoji |
Implementation Reference
- src/tools/emoji-tools.ts:123-149 (handler)Handler function that implements the core logic for modifying a Discord emoji: fetches client, guild, and emoji; builds edit data from optional name, roles, reason; edits the emoji; returns updated info or formatted error response.async ({ guildId, emojiId, name, roles, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const emoji = await guild.emojis.fetch(emojiId); const editData: { name?: string; roles?: string[]; reason?: string } = {}; if (name) editData.name = name; if (roles) editData.roles = roles; if (reason) editData.reason = reason; const updated = await emoji.edit(editData); return { id: updated.id, name: updated.name, roles: updated.roles.cache.map((r) => ({ id: r.id, name: r.name })), message: 'Emoji updated 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/tools/emoji-tools.ts:116-122 (schema)Zod schema defining the input parameters for the modify_emoji tool.{ guildId: z.string().describe('The ID of the server (guild)'), emojiId: z.string().describe('The ID of the emoji to modify'), name: z.string().optional().describe('New name for the emoji'), roles: z.array(z.string()).optional().describe('Role IDs that can use this emoji'), reason: z.string().optional().describe('Reason for modifying the emoji'), },
- src/tools/emoji-tools.ts:113-150 (registration)MCP server.tool registration for 'modify_emoji', including name, description, input schema, and handler reference.server.tool( 'modify_emoji', 'Modify a custom emoji in a server', { guildId: z.string().describe('The ID of the server (guild)'), emojiId: z.string().describe('The ID of the emoji to modify'), name: z.string().optional().describe('New name for the emoji'), roles: z.array(z.string()).optional().describe('Role IDs that can use this emoji'), reason: z.string().optional().describe('Reason for modifying the emoji'), }, async ({ guildId, emojiId, name, roles, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const emoji = await guild.emojis.fetch(emojiId); const editData: { name?: string; roles?: string[]; reason?: string } = {}; if (name) editData.name = name; if (roles) editData.roles = roles; if (reason) editData.reason = reason; const updated = await emoji.edit(editData); return { id: updated.id, name: updated.name, roles: updated.roles.cache.map((r) => ({ id: r.id, name: r.name })), message: 'Emoji updated 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:59-59 (registration)Top-level call to registerEmojiTools on the MCP server, which registers modify_emoji along with other emoji tools.registerEmojiTools(server);
- src/index.ts:16-16 (registration)Import of registerEmojiTools function that contains the modify_emoji tool registration.import { registerMessageTools } from './tools/message-tools.js';