Skip to content

Option

Implementation of the Application Command Option Structure in Luau.

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure

Properties

type

Option.type  :: apiTypes.ApplicationCommandOptionType?

The type of option (e.g., String, Integer, SubCommand).

name

Option.name  :: string?

The name of the option.

nameLocalizations

Option.nameLocalizations  :: {
      {… [apiTypes.LanguageLocales]: string …}    }

Name localizations for different language locales.

description

Option.description  :: string?

The description of the option.

descriptionLocalizations

Option.descriptionLocalizations  :: {
      {… [apiTypes.LanguageLocales]: string …}    }

Description localizations for different language locales.

required

Option.required  :: boolean?

Whether this option is required to be set by the user.

choices

Option.choices  :: { Builders.Choice.JSON }

Possible choices for this option (String, Integer, or Number types only).

options


Sub-options for this option (SubCommand or SubCommandGroup only).

apiTypes

Option.apiTypes  :: { apiTypes.ChannelType }

Supported channel types for Channel option type.

minValue

Option.minValue  :: number?

Minimum value allowed for the option (Integer/Number only).

maxValue

Option.maxValue  :: number?

Maximum value allowed for the option (Integer/Number only).

minLength

Option.minLength  :: number?

Minimum string length for the option (String only).

maxLength

Option.maxLength  :: number?

Maximum string length for the option (String only).

autocomplete

Option.autocomplete  :: boolean?

Whether autocomplete is enabled (String, Integer, or Number types only).

Methods

The Option instance has no set methods!

Functions

setType

Option . setType (

     self: Option
     type: apiTypes.ApplicationCommandOptionType
)  -> ()

Set the Type of option that will be built.

setName

Option . setName (

     self: Option
     name: string
)  -> ()

Set the name of this option, option name needs to be kebab case.

setNameLocalization

Option . setNameLocalization (

     self: Option
     localization: apiTypes.LanguageLocales
     name: string
)  -> ()

Add a name localization for this option.

setDescription

Option . setDescription (

     self: Option
     description: string
)  -> ()

Set the description of this option.

setDescriptionLocalization

Option . setDescriptionLocalization (

     self: Option
     localization: apiTypes.LanguageLocales
     description: string
)  -> ()

Add a description localization for this option.

setRequired

Option . setRequired (

     self: Option
     isRequired: boolean
)  -> ()

Set if the option is required, will not work on SubCommand or SubCommandGroup options.

addChoice

Option . addChoice (

     self: Option
     choice: interactionChoice.JSON
)  -> ()

Add a choice to the option, will only work on String, Integer, or Number options.

addOption

Option . addOption (

     self: Option
     option: JSON
)  -> ()

Add an option to the option, will only work on SubCommand or SubCommandGroup options.

addChannelType

Option . addChannelType (

     self: Option
     channelType: apiTypes.ChannelType
)  -> ()

Add supported channel types, will only work on Channel options.

setMinValue

Option . setMinValue (

     self: Option
     value: number
)  -> ()

Set the min value of this option, will only work on Integer or Number options.

setMaxValue

Option . setMaxValue (

     self: Option
     value: number
)  -> ()

Set the max value of this option, will only work on Integer or Number options.

setMinLength

Option . setMinLength (

     self: Option
     value: number
)  -> ()

Set the min length of this option, will only work on String options.

setMaxLength

Option . setMaxLength (

     self: Option
     value: number
)  -> ()

Set the max length of this option, will only work on String options.

setAutocompleteEnabled

Option . setAutocompleteEnabled (

     self: Option
     autocompleteEnabled: boolean
)  -> ()

If autocomplete interactions are enabled for this option, will only work on String, Integer, or Number options.

build

Option . build (

     self: Option
)  -> ()

Responsible for building the option object that the Discord API can understand.

new

Option . new (

     resource: {
       type: apiTypes.ApplicationCommandOptionType?,
       name: string?,
       nameLocalizations: { [apiTypes.LanguageLocales],
    }
)  -> ()

Constructor for the Discord Default Reaction Builder.