CommandOptionsBuilder class
constructor
The constructor provides one optional argument, which is an object which provides the data for the Command Options Builder.
The object may contain the following information:
name
: The name of the command option you want to create.description
: A description of what the command option does.required
: A boolean which defines whether the option is required to fill in or not.choices
: An array with raw data of the command option choices which users can choose between in the slash command.channelTypes
: An array with the channel types as a number a user will get when the user has to fill in a channel option.type
: The option type a user has as a number.minValue
: A number for when the option type is a number with the minimum number a user should provide.maxValue
: A number for when the option type is a number with the maximum number a user may provide.minLength
: The minimum length of a string when the option type is a string.maxLength
: The maximum length of a string when the option type is a string.
Argument | Description |
---|---|
data | An object with the data to create the Command Options Builder from. The data which can be added is mentioned above. |
Properties
name
The name of the command option which was set with the setName function.
description
The description of the command option which was set with the setDescription function.
required
A boolean which defines whether it is required or not to fill the command option in and was set with the setRequired function.
choices
An array with the command option choices converted to an object to make it a valid Discord API object, that have been set with the addChoices function.
channelTypes
An array with the allowed channel types for when the command option type is a channel, that have been set with the addChannelTypes function.
type
A number which defines what the command option type is and has been set with the setOptionType function.
minValue
The minimum number or integer that should be given when the command option type is a number or integer and has been set with the setMinValue function.
maxValue
The maximum number or integer that should be given when the command option type is a number or integer and has been set with the setMaxValue function.
minLength
The minimum length of the string that should be given when the command option type is a string and has been set with the setMinLength function.
maxLength
The maxmimum length of the string that should be given when the command option type is a string and has been set with the setMaxLength function.
Functions
setOptionType
Sets the type for the command and returns the same CommandOptionsBuilder class so you don't have to declare it everytime again. This is required to create a command option. The available types can be found on the CommandOptionTypes page.
Argument | Description |
---|---|
type | A number which represents the type the option should have. The available types can be found on the CommandOptionTypes page. |
setName
Sets the name for the command and returns the same CommandOptionsBuilder class so you don't have to declare it everytime again. This is required to create a command option.
Argument | Description |
---|---|
name | The name of the command option which is visible to the users using the command. |
setDescription
Sets the description for the command and returns the same CommandOptionsBuilder class so you don't have to declare it everytime again. This is required to create a command option.
Argument | Description |
---|---|
description | The description of the command option which tells what the command option does and is visible to the users using the command. |
setRequired
Defines whether the command option is required for users using the command to fill in or not and returns the same CommandOptionsBuilder class so you don't have to declare it everytime again.
Argument | Description |
---|---|
required | A boolean which defines whether the command option should be required to fill in or not. |
addChoices
Adds pre-made choices a user can choose between when using the command option and returns the same CommandOptionsBuilder class so you don't have to declare it everytime again.
Argument | Description |
---|---|
choices | An array of CommandOptionChoiceBuilder classes or a CommandOptionChoiceBuilder class which defines the choice(s) a user can choose between when using the command. |
addOptions
Adds options to the command which users can fill in in case the parent CommandOptionsBuilder is a sub command. The function returns the same CommandOptionsBuilder class so you don't have to declare it everytime again. The options will be returned to the addon once the user executes the command.
addChannelTypes
Makes sure when the command option is a channel option type that only the channel types which are given in the addChannelTypes
will be shown and not any other channel types. The function returns the CommandOptionsBuilder class so you don't have to declare it everytime again. The available types can be found on the ChannelTypes page.
Argument | Description |
---|---|
channelTypes | An array of channelTypes or a channelType as a number which defines which channel types can be chosen from when using the command option if the command option is a channel command option. The available types can be found on the ChannelTypes page. |
setMinValue
Sets the minimum number or integer which a user should give when the command option type is a number or integer and returns the CommandOptionsBuilder class so you don't have to declare it everytime again.
Argument | Description |
---|---|
min | The minimum value the user should give when the command option type is a number or integer. |
setMaxValue
Sets the maximum number or integer which a user may give when the command option type is a number or integer and returns the CommandOptionsBuilder class so you don't have to declare it everytime again.
Argument | Description |
---|---|
max | The maximum value the user may give when the command option type is a number or integer. |
setMinLength
Sets the minimum length of the string which a user should give when the command option type is a string and returns the CommandOptionsBuilder class so you don't have to declare it everytime again.
Argument | Description |
---|---|
min | The minimum length of a string which a user should give when the command option type is a string. |
setMaxLength
Sets the maximum length of the string which a user should give when the command option type is a string and returns the CommandOptionsBuilder class so you don't have to declare it everytime again.
Argument | Description |
---|---|
max | The maximum length of a string which a user should give when the command option type is a string. |
toJSON
Converts the CommandBuilder to an object to make it a valid object for the Discord API.
Last updated