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

Summary

Option.type  :: ApplicationCommandOptionType?

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

Option.name  :: string?

The name of the option.

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

Name localizations for different language locales.

Option.description  :: string?

The description of the option.

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

Description localizations for different language locales.

Option.required  :: boolean?

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

Option.choices  :: JSON }

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

Option.options  :: JSON }

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

Option.channelTypes  :: ChannelType }

Supported channel types for Channel option type.

Option.minValue  :: number?

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

Option.maxValue  :: number?

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

Option.minLength  :: number?

Minimum string length for the option (String only).

Option.maxLength  :: number?

Maximum string length for the option (String only).

Option.autocomplete  :: boolean?

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

Option : setType ( type )  -> Option

Set the Type of option that will be built.

Parameters

type: ApplicationCommandOptionType

Returns

Option
Option : setName ( name )  -> Option

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

Parameters

name: string

Returns

Option
Option : setNameLocalization ( localization name )  -> Option

Add a name localization for this option.

Parameters

localization: LanguageLocales
name: string

Returns

Option
Option : setDescription ( description )  -> Option

Set the description of this option.

Parameters

description: string

Returns

Option
Option : setDescriptionLocalization ( localization description )  -> Option

Add a description localization for this option.

Parameters

localization: LanguageLocales
description: string

Returns

Option
Option : setRequired ( isRequired )  -> Option

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

Parameters

isRequired: boolean

Returns

Option
Option : addChoice ( choice )  -> Option

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

Parameters

choice: JSON

Returns

Option
Option : addOption ( option )  -> Option

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

Parameters

option: JSON

Returns

Option
Option : addChannelType ( channelType )  -> Option

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

Parameters

channelType: ChannelType

Returns

Option
Option : setMinValue ( value )  -> Option

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

Parameters

value: number

Returns

Option
Option : setMaxValue ( value )  -> Option

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

Parameters

value: number

Returns

Option
Option : setMinLength ( value )  -> Option

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

Parameters

value: number

Returns

Option
Option : setMaxLength ( value )  -> Option

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

Parameters

value: number

Returns

Option
Option : setAutocompleteEnabled ( autocompleteEnabled )  -> Option

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

Parameters

autocompleteEnabled: boolean

Returns

Option
Option : build ( )  -> JSON

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

Returns

JSON
Option . new ( resource )  -> Option

Constructor for the Discord Default Reaction Builder.

Parameters

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

Returns

Option