Trying to start a scheduled event

I'm running into an error when trying to start a scheduled event: Error:
DiscordAPIError[50035]: Invalid Form Body
status[NUMBER_TYPE_COERCE]: Value "2023-03-31T23:50:00.000Z" is not int.
at SequentialHandler.runRequest (C:\Users\John\source\repos\UltimatumsBot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:498:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at SequentialHandler.queueRequest (C:\Users\John\source\repos\UltimatumsBot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:198:11)
at REST.request (C:\Users\John\source\repos\UltimatumsBot\node_modules\@discordjs\rest\src\lib\REST.ts:343:20)
at GuildScheduledEventManager.edit (C:\Users\John\source\repos\UltimatumsBot\node_modules\discord.js\src\managers\GuildScheduledEventManager.js:215:18)
at Object.updateScheduledEventStatus (C:\Users\John\source\repos\UltimatumsBot\src\bot\events\PVMEvent.ts:70:3)
DiscordAPIError[50035]: Invalid Form Body
status[NUMBER_TYPE_COERCE]: Value "2023-03-31T23:50:00.000Z" is not int.
at SequentialHandler.runRequest (C:\Users\John\source\repos\UltimatumsBot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:498:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at SequentialHandler.queueRequest (C:\Users\John\source\repos\UltimatumsBot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:198:11)
at REST.request (C:\Users\John\source\repos\UltimatumsBot\node_modules\@discordjs\rest\src\lib\REST.ts:343:20)
at GuildScheduledEventManager.edit (C:\Users\John\source\repos\UltimatumsBot\node_modules\discord.js\src\managers\GuildScheduledEventManager.js:215:18)
at Object.updateScheduledEventStatus (C:\Users\John\source\repos\UltimatumsBot\src\bot\events\PVMEvent.ts:70:3)
Creation Code:
const scheduledEvent = await interaction.guild.scheduledEvents.create({
channel: implementation.voiceChannelId,
name: implementation.title,
entityType: GuildScheduledEventEntityType.Voice,
privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,
// these are valid times as the UI is working as intended
scheduledStartTime: eventTime.unix() * 1000,
scheduledEndTime: (eventTime.unix() + 60 * 60 * 1000) * 1000,
});
const scheduledEvent = await interaction.guild.scheduledEvents.create({
channel: implementation.voiceChannelId,
name: implementation.title,
entityType: GuildScheduledEventEntityType.Voice,
privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,
// these are valid times as the UI is working as intended
scheduledStartTime: eventTime.unix() * 1000,
scheduledEndTime: (eventTime.unix() + 60 * 60 * 1000) * 1000,
});
Starting Code:
const event = await FETCH_FROM_API(id);
const guild = await client.guilds.fetch(GUILD_ID);
// get the scheduled event
const scheduledEvent = await guild.scheduledEvents.fetch(event.scheduledEventId);
// start the event
await scheduledEvent.setStatus(GuildScheduledEventStatus.Active);
const event = await FETCH_FROM_API(id);
const guild = await client.guilds.fetch(GUILD_ID);
// get the scheduled event
const scheduledEvent = await guild.scheduledEvents.fetch(event.scheduledEventId);
// start the event
await scheduledEvent.setStatus(GuildScheduledEventStatus.Active);
I am manually able to start the event from the UI, but not from code?
9 Replies
d.js toolkit
d.js toolkit16mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
duck
duck16mo ago
just to confirm, PVMEvent.ts line 70 is where you call setStatus?
nullopt
nullopt16mo ago
yes
duck
duck16mo ago
interesting, as your code doesn't match your error the stack trace should read that you called GuildScheduledEvent.setStatus, which would then call GuildScheduledEventManager.edit I'm not even entirely sure where that date string is coming from, but GuildScheduledEventStatus.Active's value is 2 the code you've shown has no issues on my end if you're using something like ts-node, you could also consider actually compiling
nullopt
nullopt16mo ago
Yeah, honestly wasn't sure myself
duck
duck16mo ago
since this code is a little different, could you also log status just to make sure?
nullopt
nullopt16mo ago
@ducktrshessami I am very sorry to have wasted your time... Please forget you ever read this ticket PEPELA so I had originally hard coded the Active status, but changed the signature of the function to be dynamic. But... I didn't change the calls to the functions... Facepalm working as intended now
duck
duck16mo ago
no worries lol