Slash Commands (Subcommand)

const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('database')
.setDescription('Access to the PA Admins database.')
.addSubcommand(users =>
users
.setName('users')
.setDescription('Access the Users Database.')
.addIntegerOption(userOption1 =>
userOption1
.setName('bots')
.setDescription('Bot Information.')
.addChoices(
{name: 'Dyno', value: 'dyno'},
{name: 'Member Count', value: 'member count'},
{name: 'Sapphire', value: 'sapphire'},
{name: 'Ticket Tool', value: 'ticket tool'},
{name: 'UnbelievaBoat', value: 'unbelievaboat'},
)
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('database')
.setDescription('Access to the PA Admins database.')
.addSubcommand(users =>
users
.setName('users')
.setDescription('Access the Users Database.')
.addIntegerOption(userOption1 =>
userOption1
.setName('bots')
.setDescription('Bot Information.')
.addChoices(
{name: 'Dyno', value: 'dyno'},
{name: 'Member Count', value: 'member count'},
{name: 'Sapphire', value: 'sapphire'},
{name: 'Ticket Tool', value: 'ticket tool'},
{name: 'UnbelievaBoat', value: 'unbelievaboat'},
)
Error
throw this.error;
^

ValidationError: Expected a number primitive
at NumberValidator.handle (D:\PA_Admin Backup\node_modules\@sapphire\shapeshift\dist\index.js:896:70)
at NumberValidator.parse (D:\PA_Admin Backup\node_modules\@sapphire\shapeshift\dist\index.js:142:88)
at MixedClass.addChoices (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1054:25)
at D:\PA_Admin Backup\Slash Commands\database.js:14:22
at MixedClass._sharedAddOptionMethod (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1256:50)
at MixedClass.addIntegerOption (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1248:17)
at D:\PA_Admin Backup\Slash Commands\database.js:10:14
at MixedClass.addSubcommand (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1365:50)
at Object.<anonymous> (D:\PA_Admin Backup\Slash Commands\database.js:6:6)
at Module._compile (node:internal/modules/cjs/loader:1103:14) {
validator: 's.number',
given: 'dyno'
}
throw this.error;
^

ValidationError: Expected a number primitive
at NumberValidator.handle (D:\PA_Admin Backup\node_modules\@sapphire\shapeshift\dist\index.js:896:70)
at NumberValidator.parse (D:\PA_Admin Backup\node_modules\@sapphire\shapeshift\dist\index.js:142:88)
at MixedClass.addChoices (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1054:25)
at D:\PA_Admin Backup\Slash Commands\database.js:14:22
at MixedClass._sharedAddOptionMethod (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1256:50)
at MixedClass.addIntegerOption (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1248:17)
at D:\PA_Admin Backup\Slash Commands\database.js:10:14
at MixedClass.addSubcommand (D:\PA_Admin Backup\node_modules\@discordjs\builders\dist\index.js:1365:50)
at Object.<anonymous> (D:\PA_Admin Backup\Slash Commands\database.js:6:6)
at Module._compile (node:internal/modules/cjs/loader:1103:14) {
validator: 's.number',
given: 'dyno'
}
2 Replies
PAdventures
PAdventuresOP3y ago
nvm i just realised
Almeida
Almeida3y ago
the type of the choice values must match the type of the option
Want results from more Discord servers?
Add your server