Slash Command Builder Default Option Values

Good morning all!

discord.js@14.13.0
node v18.12.0

I'm working w/ SlashCommandBuilder and am trying to figure out how to set a default value for an option (e.g. String, Boolean, etc.) in the event the user doesn't provide a value

For example,

...
.addBooleanOption(option =>
            option.setName('private')
                .setDescription('Post to just you or public')


I would want to use something like .setDefault(true) so if the user didn't give anything I could use private to do something like

const private = interaction.options.getBoolean('private')
interaction.reply({content: 'Hello there', ephemeral: private})


Where it posts an ephemeral post by default unless the user explicitly sets private to
false


I've also tried logging the value of private with and without user input to see if I can bootleg my way around it but always get
null
for some reason...

Any help would be appreciated! Thanks!
Was this page helpful?