Error while adding option to command.

Whenever I try to add an option to my command, it breaks. Can anyone tell me why? My commands:
var modCommandsList = [
['ban', 'Bans the specified user.', 'user', true],
['kick', 'Kicks the specified user.', 'user', true],
['report', 'Reports the specified user to moderators.', 'user', true],
]
var modCommandsList = [
['ban', 'Bans the specified user.', 'user', true],
['kick', 'Kicks the specified user.', 'user', true],
['report', 'Reports the specified user to moderators.', 'user', true],
]
My SlashCommandBuilder:
for (const i in modCommandsList) {
modCommands.push(
new SlashCommandBuilder()
.setName(modCommandsList[i][0])
.setDescription(modCommandsList[i][1])
.addUserOption((option) => {
option.setName(modCommandsList[i][2]).setDescription(modCommandsList[i][2]).setRequired(modCommandsList[i][3])
})
)
}
for (const i in modCommandsList) {
modCommands.push(
new SlashCommandBuilder()
.setName(modCommandsList[i][0])
.setDescription(modCommandsList[i][1])
.addUserOption((option) => {
option.setName(modCommandsList[i][2]).setDescription(modCommandsList[i][2]).setRequired(modCommandsList[i][3])
})
)
}
My command register system:
try {
console.log('Started refreshing application (/) commands.')
rest.put(Routes.applicationCommands(CLIENT_ID), { body: modCommands })
console.log('Successfully reloaded application (/) commands.')
} catch (error) {
console.error(error)
}
try {
console.log('Started refreshing application (/) commands.')
rest.put(Routes.applicationCommands(CLIENT_ID), { body: modCommands })
console.log('Successfully reloaded application (/) commands.')
} catch (error) {
console.error(error)
}
No description
4 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!
treble/luna
treble/luna6mo ago
remove {} or return your option in your addUserOption
Syjalo
Syjalo6mo ago
The option should be returned from the callback. Remove {} or add return
reallyBadDev();
reallyBadDev();OP6mo ago
got it thanks worked thanks
Want results from more Discord servers?
Add your server