Skip to main content
Glama

list_events

Retrieve all scheduled events in a Discord server with optional user count data to manage and track community activities.

Instructions

List all scheduled events in a server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
withUserCountNoInclude user count (default true)

Implementation Reference

  • Handler function that fetches scheduled events from the Discord guild using the Discord.js client, maps them to a structured format, handles errors with withErrorHandling, and returns JSON stringified content.
    async ({ guildId, withUserCount = true }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const events = await guild.scheduledEvents.fetch({ withUserCount }); return events.map((event) => ({ id: event.id, name: event.name, description: event.description, scheduledStartTime: event.scheduledStartAt?.toISOString(), scheduledEndTime: event.scheduledEndAt?.toISOString(), privacyLevel: GuildScheduledEventPrivacyLevel[event.privacyLevel], status: GuildScheduledEventStatus[event.status], entityType: GuildScheduledEventEntityType[event.entityType], entityId: event.entityId, channelId: event.channelId, creatorId: event.creatorId, userCount: event.userCount, location: event.entityMetadata?.location, image: event.coverImageURL(), url: event.url, })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Input schema using Zod for validating guildId (required string) and optional withUserCount (boolean).
    guildId: z.string().describe('The ID of the server (guild)'), withUserCount: z.boolean().optional().describe('Include user count (default true)'), },
  • Registration of the 'list_events' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.
    server.tool( 'list_events', 'List all scheduled events in a server', { guildId: z.string().describe('The ID of the server (guild)'), withUserCount: z.boolean().optional().describe('Include user count (default true)'), }, async ({ guildId, withUserCount = true }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const events = await guild.scheduledEvents.fetch({ withUserCount }); return events.map((event) => ({ id: event.id, name: event.name, description: event.description, scheduledStartTime: event.scheduledStartAt?.toISOString(), scheduledEndTime: event.scheduledEndAt?.toISOString(), privacyLevel: GuildScheduledEventPrivacyLevel[event.privacyLevel], status: GuildScheduledEventStatus[event.status], entityType: GuildScheduledEventEntityType[event.entityType], entityId: event.entityId, channelId: event.channelId, creatorId: event.creatorId, userCount: event.userCount, location: event.entityMetadata?.location, image: event.coverImageURL(), url: event.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:62-62 (registration)
    Call to registerEventTools(server) which includes the list_events tool registration, within the createMcpServer function.
    registerEventTools(server);
  • src/index.ts:20-20 (registration)
    Import of registerEventTools from event-tools.js to enable tool registration.
    import { registerEventTools } from './tools/event-tools.js';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scarecr0w12/discord-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server