Skip to main content
Glama

create_event

Schedule events in Discord servers by specifying details like name, time, type, and location for voice, stage, or external gatherings.

Instructions

Create a scheduled event in a server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
nameYesName of the event
descriptionNoDescription of the event
scheduledStartTimeYesStart time in ISO 8601 format
scheduledEndTimeNoEnd time in ISO 8601 format (required for external events)
entityTypeYesType of event
channelIdNoChannel ID for voice/stage events
locationNoLocation for external events
imageNoURL of the cover image
reasonNoReason for creating

Implementation Reference

  • The handler function that executes the create_event tool: fetches Discord guild, maps entity type, constructs event options, creates the scheduled event using guild.scheduledEvents.create(), and returns the result or error.
    async ({ guildId, name, description, scheduledStartTime, scheduledEndTime, entityType, channelId, location, image, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const entityTypeMap: Record<string, GuildScheduledEventEntityType> = { 'STAGE_INSTANCE': GuildScheduledEventEntityType.StageInstance, 'VOICE': GuildScheduledEventEntityType.Voice, 'EXTERNAL': GuildScheduledEventEntityType.External, }; const eventOptions: { name: string; scheduledStartTime: string; privacyLevel: GuildScheduledEventPrivacyLevel; entityType: GuildScheduledEventEntityType; description?: string; scheduledEndTime?: string; channel?: string; entityMetadata?: { location: string }; image?: string; reason?: string; } = { name, scheduledStartTime, privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly, entityType: entityTypeMap[entityType], }; if (description) eventOptions.description = description; if (scheduledEndTime) eventOptions.scheduledEndTime = scheduledEndTime; if (channelId) eventOptions.channel = channelId; if (location) eventOptions.entityMetadata = { location }; if (image) eventOptions.image = image; if (reason) eventOptions.reason = reason; const event = await guild.scheduledEvents.create(eventOptions); return { id: event.id, name: event.name, scheduledStartTime: event.scheduledStartAt?.toISOString(), entityType: GuildScheduledEventEntityType[event.entityType], url: event.url, message: 'Event 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) }] }; }
  • Zod input schema defining parameters for the create_event tool, including guildId, name, times, entityType, etc.
    { guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name of the event'), description: z.string().optional().describe('Description of the event'), scheduledStartTime: z.string().describe('Start time in ISO 8601 format'), scheduledEndTime: z.string().optional().describe('End time in ISO 8601 format (required for external events)'), entityType: z.enum(['STAGE_INSTANCE', 'VOICE', 'EXTERNAL']).describe('Type of event'), channelId: z.string().optional().describe('Channel ID for voice/stage events'), location: z.string().optional().describe('Location for external events'), image: z.string().optional().describe('URL of the cover image'), reason: z.string().optional().describe('Reason for creating'), },
  • Registration of the create_event tool using server.tool() within registerEventTools function, including name, description, schema, and handler.
    server.tool( 'create_event', 'Create a scheduled event in a server', { guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name of the event'), description: z.string().optional().describe('Description of the event'), scheduledStartTime: z.string().describe('Start time in ISO 8601 format'), scheduledEndTime: z.string().optional().describe('End time in ISO 8601 format (required for external events)'), entityType: z.enum(['STAGE_INSTANCE', 'VOICE', 'EXTERNAL']).describe('Type of event'), channelId: z.string().optional().describe('Channel ID for voice/stage events'), location: z.string().optional().describe('Location for external events'), image: z.string().optional().describe('URL of the cover image'), reason: z.string().optional().describe('Reason for creating'), }, async ({ guildId, name, description, scheduledStartTime, scheduledEndTime, entityType, channelId, location, image, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const entityTypeMap: Record<string, GuildScheduledEventEntityType> = { 'STAGE_INSTANCE': GuildScheduledEventEntityType.StageInstance, 'VOICE': GuildScheduledEventEntityType.Voice, 'EXTERNAL': GuildScheduledEventEntityType.External, }; const eventOptions: { name: string; scheduledStartTime: string; privacyLevel: GuildScheduledEventPrivacyLevel; entityType: GuildScheduledEventEntityType; description?: string; scheduledEndTime?: string; channel?: string; entityMetadata?: { location: string }; image?: string; reason?: string; } = { name, scheduledStartTime, privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly, entityType: entityTypeMap[entityType], }; if (description) eventOptions.description = description; if (scheduledEndTime) eventOptions.scheduledEndTime = scheduledEndTime; if (channelId) eventOptions.channel = channelId; if (location) eventOptions.entityMetadata = { location }; if (image) eventOptions.image = image; if (reason) eventOptions.reason = reason; const event = await guild.scheduledEvents.create(eventOptions); return { id: event.id, name: event.name, scheduledStartTime: event.scheduledStartAt?.toISOString(), entityType: GuildScheduledEventEntityType[event.entityType], url: event.url, message: 'Event 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:62-62 (registration)
    Main registration call in index.ts that invokes registerEventTools(server) to register all event tools including create_event.
    registerEventTools(server);

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