Required options must be placed before non-required options

im trying to register some slash commands, but specifically 2 are failing.
83.options[3][APPLICATION_COMMAND_OPTIONS_REQUIRED_INVALID]: Required options must be placed before non-required options
98.options[1][APPLICATION_COMMAND_OPTIONS_REQUIRED_INVALID]: Required options must be placed before non-required options
83.options[3][APPLICATION_COMMAND_OPTIONS_REQUIRED_INVALID]: Required options must be placed before non-required options
98.options[1][APPLICATION_COMMAND_OPTIONS_REQUIRED_INVALID]: Required options must be placed before non-required options
how can i make sure im looking at the right one? i think, one should be this:
module.exports = {
data: new SlashCommandBuilder()
.setName('volume')
.setDescription('Set the playback volume (0-100).')
.addIntegerOption(option =>
option.setName('amount')
.setDescription('Volume amount (0-100)')
.setRequired(true)
.setMinValue(0)
.setMaxValue(100)),
async execute(client, interaction) {
}
}
module.exports = {
data: new SlashCommandBuilder()
.setName('volume')
.setDescription('Set the playback volume (0-100).')
.addIntegerOption(option =>
option.setName('amount')
.setDescription('Volume amount (0-100)')
.setRequired(true)
.setMinValue(0)
.setMaxValue(100)),
async execute(client, interaction) {
}
}
but i dont see anything wrong!
11 Replies
d.js toolkit
d.js toolkit6mo 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 OP
souji
souji6mo ago
it cannot be the one you show, because that only has a single option as the error states, two of your commands have a non-required option before a required one -# also please tell me i'm interpreting this wrong and it's not commands 83 and 98 (please tell me you don't have 98 commands... that's absurd)
#Intel
#IntelOP6mo ago
i have 103 commands, thats the 98th one 💔 ive been running this ps code:
$i = 1; Get-ChildItem -Path ".\slashCommands" -Recurse -Filter "*.js" | Sort-Object Name | ForEach-Object { "$i. $($_.FullName)"; $i++ }
$i = 1; Get-ChildItem -Path ".\slashCommands" -Recurse -Filter "*.js" | Sort-Object Name | ForEach-Object { "$i. $($_.FullName)"; $i++ }
to retrieve the exact path for all my commands to see which one are 83 and 98
souji
souji6mo ago
no bot needs that many commands... but yes, then it's probably 83 option 3 and 98 option 1 that are problematic
#Intel
#IntelOP6mo ago
83
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ticketpanel')
.setDescription('Create a ticket panel')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option =>
option.setName('title')
.setDescription('Title for the ticket panel')
.setRequired(true))
.addChannelOption(option =>
option.setName('channel')
.setDescription('Channel to send the panel to')
.setRequired(true))
.addRoleOption(option =>
option.setName('support_role')
.setDescription('Role that can see tickets')
.setRequired(true))
.addStringOption(option =>
option.setName('description')
.setDescription('Panel description')
.setRequired(false))
.addStringOption(option =>
option.setName('button_text')
.setDescription('Text to show on the button')
.setRequired(false)),
async execute(client, interaction) {
const title = interaction.options.getString('title');
const description = interaction.options.getString('description');
const buttonText = interaction.options.getString('button_text');
const channel = interaction.options.getChannel('channel');
const supportRole = interaction.options.getRole('support_role');

const ticketEmbed = new EmbedBuilder()
.setTitle(title)
.setDescription(description || 'No description provided')
.setColor('Aqua');

const ticketButton = new ButtonBuilder()
.setCustomId('create_ticket')
.setLabel(buttonText || 'Create Ticket')
.setStyle(ButtonStyle.Primary);

removed cuz no space
}
};
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ticketpanel')
.setDescription('Create a ticket panel')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option =>
option.setName('title')
.setDescription('Title for the ticket panel')
.setRequired(true))
.addChannelOption(option =>
option.setName('channel')
.setDescription('Channel to send the panel to')
.setRequired(true))
.addRoleOption(option =>
option.setName('support_role')
.setDescription('Role that can see tickets')
.setRequired(true))
.addStringOption(option =>
option.setName('description')
.setDescription('Panel description')
.setRequired(false))
.addStringOption(option =>
option.setName('button_text')
.setDescription('Text to show on the button')
.setRequired(false)),
async execute(client, interaction) {
const title = interaction.options.getString('title');
const description = interaction.options.getString('description');
const buttonText = interaction.options.getString('button_text');
const channel = interaction.options.getChannel('channel');
const supportRole = interaction.options.getRole('support_role');

const ticketEmbed = new EmbedBuilder()
.setTitle(title)
.setDescription(description || 'No description provided')
.setColor('Aqua');

const ticketButton = new ButtonBuilder()
.setCustomId('create_ticket')
.setLabel(buttonText || 'Create Ticket')
.setStyle(ButtonStyle.Primary);

removed cuz no space
}
};
98
const { SlashCommandBuilder, MessageFlags } = require('discord.js');
const { queue } = require('../../utils/music');

module.exports = {
data: new SlashCommandBuilder()
.setName('volume')
.setDescription('Set the playback volume (0-100).')
.addIntegerOption(option =>
option.setName('amount')
.setDescription('Volume amount (0-100)')
.setRequired(true)
.setMinValue(0)
.setMaxValue(100)),
async execute(client, interaction) {
const serverQueue = queue.get(interaction.guild.id);
if (!serverQueue) {
return interaction.reply({
content: 'Nothing is playing!',
flags: MessageFlags.Ephemeral
});
}
const vol = interaction.options.getInteger('amount');
serverQueue.volume = vol / 100;
if (serverQueue.player.state.resource?.volume) {
serverQueue.player.state.resource.volume.setVolume(serverQueue.volume);
}
await interaction.reply({
content: `🔊 Volume set to **${vol}%**`,
flags: MessageFlags.Ephemeral
});
}
};
const { SlashCommandBuilder, MessageFlags } = require('discord.js');
const { queue } = require('../../utils/music');

module.exports = {
data: new SlashCommandBuilder()
.setName('volume')
.setDescription('Set the playback volume (0-100).')
.addIntegerOption(option =>
option.setName('amount')
.setDescription('Volume amount (0-100)')
.setRequired(true)
.setMinValue(0)
.setMaxValue(100)),
async execute(client, interaction) {
const serverQueue = queue.get(interaction.guild.id);
if (!serverQueue) {
return interaction.reply({
content: 'Nothing is playing!',
flags: MessageFlags.Ephemeral
});
}
const vol = interaction.options.getInteger('amount');
serverQueue.volume = vol / 100;
if (serverQueue.player.state.resource?.volume) {
serverQueue.player.state.resource.volume.setVolume(serverQueue.volume);
}
await interaction.reply({
content: `🔊 Volume set to **${vol}%**`,
flags: MessageFlags.Ephemeral
});
}
};
souji
souji6mo ago
ok, now look at them
#Intel
#IntelOP6mo ago
they dont have issue that my eyes see
souji
souji6mo ago
true true true false false => not the issue just one option => not the issue => not the right commands
#Intel
#IntelOP6mo ago
uh i might have found one
No description
souji
souji6mo ago
yup
#Intel
#IntelOP6mo ago
great ill search the other one thank you

Did you find this page helpful?