create_emoji
Add custom emojis to Discord servers by uploading images, naming them, and setting usage permissions for enhanced community expression.
Instructions
Create a custom emoji in a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| name | Yes | Name for the emoji | |
| imageUrl | Yes | URL of the image to use (must be < 256KB) | |
| roles | No | Role IDs that can use this emoji | |
| reason | No | Reason for creating the emoji |
Implementation Reference
- src/tools/emoji-tools.ts:53-80 (handler)The handler function that implements the core logic of the create_emoji tool. It fetches the Discord guild, creates the emoji using the provided image URL and parameters, handles errors, and formats the response.async ({ guildId, name, imageUrl, roles, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const emoji = await guild.emojis.create({ attachment: imageUrl, name, roles, reason, }); return { id: emoji.id, name: emoji.name, animated: emoji.animated, identifier: emoji.identifier, url: emoji.url, message: 'Emoji created 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:46-52 (schema)Zod input schema defining parameters for the create_emoji tool: guildId (required), name (required), imageUrl (required), roles (optional array), reason (optional).{ guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name for the emoji'), imageUrl: z.string().describe('URL of the image to use (must be < 256KB)'), roles: z.array(z.string()).optional().describe('Role IDs that can use this emoji'), reason: z.string().optional().describe('Reason for creating the emoji'), },
- src/tools/emoji-tools.ts:44-81 (registration)Registers the create_emoji tool on the MCP server within the registerEmojiTools function, specifying name, description, input schema, and handler.'create_emoji', 'Create a custom emoji in a server', { guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name for the emoji'), imageUrl: z.string().describe('URL of the image to use (must be < 256KB)'), roles: z.array(z.string()).optional().describe('Role IDs that can use this emoji'), reason: z.string().optional().describe('Reason for creating the emoji'), }, async ({ guildId, name, imageUrl, roles, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const emoji = await guild.emojis.create({ attachment: imageUrl, name, roles, reason, }); return { id: emoji.id, name: emoji.name, animated: emoji.animated, identifier: emoji.identifier, url: emoji.url, message: 'Emoji created 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(server) in createMcpServer function, which in turn registers the create_emoji tool among others.registerEmojiTools(server);
- src/index.ts:17-17 (registration)Import of registerEmojiTools from emoji-tools.ts in the main index.ts file.import { registerEmojiTools } from './tools/emoji-tools.js';