create_emoji
Add custom emojis to Discord servers by uploading images and configuring 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 executes the create_emoji tool: fetches the Discord guild and creates the emoji using guild.emojis.create(), handles errors with withErrorHandling, and returns JSON 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)Input schema for create_emoji tool using Zod validation for parameters: guildId, name, imageUrl, optional roles and reason.{ 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)Registration of the create_emoji tool on the MCP server using server.tool(), including name, description, 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:60-60 (registration)Call to registerEmojiTools(server) which registers all emoji tools including create_emoji.registerEmojiTools(server);