Error : Could not resolve channel to GUILD_VOICE

im trying to create an event through slashCommandBuilder but it doesnt seem to work. the params are passed succesffuly but in the end i get the error that the "location cant be resolved to a guild voice channel" please help me get through this ill really really appreciate
No description
4 Replies
d.js toolkit
d.js toolkit5mo 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!
! Midny
! MidnyOP5mo ago
const { SlashCommandBuilder } = require('discord.js'); const { getGuild } = require("../guildHandler"); module.exports = { delete: true, data: new SlashCommandBuilder() .setName('create') .setDescription('Creates an Event on the Server!') .addStringOption(option => option.setName('name') .setDescription('Name of the event') .setRequired(true)) .addStringOption(option => option.setName('description') .setDescription('Description of the event') .setRequired(true)) .addStringOption(option => option.setName('starttime') .setDescription('Start time of the event (ISO format)') .setRequired(true)) .addStringOption(option => option.setName('endtime') .setDescription('End time of the event (ISO format)') .setRequired(true)) .addChannelOption(option => option.setName('location') .setDescription('Location of the event (Voice Channel)') .setRequired(true)) .addIntegerOption(option => option.setName('privacylevel') .setDescription('Privacy level of the event (1 = Public, 2 = Guild Only)') .setRequired(false)), run: async ({ interaction }) => { const name = interaction.options.getString('name'); const description = interaction.options.getString('description'); const startTime = interaction.options.getString('starttime'); const endTime = interaction.options.getString('endtime'); const location = interaction.options.getChannel('location'); const privacyLevel = interaction.options.getInteger('privacylevel') || 1; // Default to public if not provided const isValidDate = (dateString) => { const regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/; return regex.test(dateString); }; if (!isValidDate(startTime) || !isValidDate(endTime)) { return interaction.reply("Invalid date format. Please use ISO format."); } console.log(location) const guild = getGuild(); if (!guild) { return interaction.reply("Guild not found."); } try { const event = await guild.scheduledEvents.create({ name, description, scheduledStartTime: new Date(startTime).toISOString(), scheduledEndTime: new Date(endTime).toISOString(), location: location.id, // Use channel ID here privacyLevel }); await interaction.reply(Created an event with the following details:\n```json\n${JSON.stringify(event, null, 2)}\n```); } catch (error) { console.error("Error creating event:", error); await interaction.reply("There was an error creating the event."); } } }; heres the code yeah
d.js docs
d.js docs5mo ago
:interface: GuildScheduledEventCreateOptions @14.15.3 Options used to create a guild scheduled event.
! Midny
! MidnyOP5mo ago
alroght thank u
Want results from more Discord servers?
Add your server