list_emojis
Retrieve all custom emojis from a Discord server by providing the guild ID to manage and organize server emoji collections.
Instructions
List all custom emojis in a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) |
Implementation Reference
- src/tools/emoji-tools.ts:14-39 (handler)The handler function that fetches all custom emojis from the specified Discord guild using the Discord client, maps them to a detailed JSON structure, and returns the result wrapped in MCP content format with error handling.async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const emojis = await guild.emojis.fetch(); return emojis.map((emoji) => ({ id: emoji.id, name: emoji.name, animated: emoji.animated, available: emoji.available, managed: emoji.managed, requiresColons: emoji.requiresColons, roles: emoji.roles.cache.map((r) => ({ id: r.id, name: r.name })), author: emoji.author ? { id: emoji.author.id, username: emoji.author.username } : null, identifier: emoji.identifier, url: emoji.url, })); }); 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:11-13 (schema)Zod schema defining the input parameters for the list_emojis tool: guildId (string, required).{ guildId: z.string().describe('The ID of the server (guild)'), },
- src/tools/emoji-tools.ts:8-40 (registration)Registers the list_emojis tool on the MCP server with its name, description, input schema, and handler function.server.tool( 'list_emojis', 'List all custom emojis in a server', { guildId: z.string().describe('The ID of the server (guild)'), }, async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const emojis = await guild.emojis.fetch(); return emojis.map((emoji) => ({ id: emoji.id, name: emoji.name, animated: emoji.animated, available: emoji.available, managed: emoji.managed, requiresColons: emoji.requiresColons, roles: emoji.roles.cache.map((r) => ({ id: r.id, name: r.name })), author: emoji.author ? { id: emoji.author.id, username: emoji.author.username } : null, identifier: emoji.identifier, url: emoji.url, })); }); 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)Top-level registration call that invokes registerEmojiTools to add all emoji-related tools, including list_emojis, to the MCP server.registerEmojiTools(server);
- src/index.ts:17-17 (registration)Import statement for the registerEmojiTools function that contains the list_emojis tool registration.import { registerEmojiTools } from './tools/emoji-tools.js';