Creating an event via a bot.

Good evening! Please tell me if it is possible to create such events using a bot? I didn't find anything like this in the documentation, programmer chats, and online videos. I hope you can help with at least a little hint. Thank you in advance.
No description
8 Replies
d.js toolkit
d.js toolkit7d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
d.js docs
d.js docs7d ago
:method: GuildScheduledEventManager#create() @14.16.3 Creates a new guild scheduled event.
Amgelo
Amgelo7d ago
and you get that via:
d.js docs
d.js docs7d ago
:property: Guild#scheduledEvents @14.16.3 A manager of the scheduled events of this guild
Michel Migalov
Michel MigalovOP7d ago
const { clientId, guildId, token } = require("../../config.json");
const { SlashCommandBuilder, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('event')
.setDescription('a test command'),

async execute(interaction) {

const guild = interaction.client.guilds.cache.get(guildId);

if (!guild) return console.log('Guild not found');

const eventOptions = {
name: 'My Event',
scheduledStartTime: new Date('2025-10-01T12:00:00Z'),
scheduledEndTime: new Date('2025-10-01T13:00:00Z'),
description: 'This is a test event.',
entityType: GuildScheduledEventEntityType.Voice,
privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,
};

try {
const scheduledEvent = await guild.scheduledEvents.create(eventOptions);
console.log(`Event created: ${scheduledEvent.name}`);
} catch (error) {
console.error('Error creating event:', error);
}
},
};
const { clientId, guildId, token } = require("../../config.json");
const { SlashCommandBuilder, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('event')
.setDescription('a test command'),

async execute(interaction) {

const guild = interaction.client.guilds.cache.get(guildId);

if (!guild) return console.log('Guild not found');

const eventOptions = {
name: 'My Event',
scheduledStartTime: new Date('2025-10-01T12:00:00Z'),
scheduledEndTime: new Date('2025-10-01T13:00:00Z'),
description: 'This is a test event.',
entityType: GuildScheduledEventEntityType.Voice,
privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,
};

try {
const scheduledEvent = await guild.scheduledEvents.create(eventOptions);
console.log(`Event created: ${scheduledEvent.name}`);
} catch (error) {
console.error('Error creating event:', error);
}
},
};
Error creating event: Error [GuildVoiceChannelResolve]: Could not resolve channel to a guild voice channel.
Error creating event: Error [GuildVoiceChannelResolve]: Could not resolve channel to a guild voice channel.
It is not very clear how to arrange the entered values.
NyR
NyR7d ago
You did not provide the channel option
d.js docs
d.js docs7d ago
:propertysignature: GuildScheduledEventCreateOptions#channel @14.16.3 The channel of the guild scheduled event This is required if entityType is GuildScheduledEventEntityType.StageInstance or GuildScheduledEventEntityType.Voice
Michel Migalov
Michel MigalovOP7d ago
It's working! Thank you very much! I thought it was impossible to create such a thing.
Want results from more Discord servers?
Add your server