Slash
Slash
A class representing a Discord Slash Command.
Kind: global class
- Slash
- new Slash([data])
- .setType(type) ⇒
Slash
- .setName(name) ⇒
Slash
- .setDescriptionLocalizations(description) ⇒
Slash
- .setNameLocalizations([localizations]) ⇒
Slash
- .setDescription(description) ⇒
Slash
- .setDefaultMemberPermissions(…permission) ⇒
Slash
- .setDmPermission(permission) ⇒
Slash
- .setOptions(fn) ⇒
Slash
- .addSubCommandGroups(fn) ⇒
Slash
- .addSubCommands(fn) ⇒
Slash
- .validation()
- .toJSON() ⇒
Object
new Slash([data])
Param | Type | Default | Description |
---|---|---|---|
[data] | Object | The data for the Slash Command. | |
[data.type] | number | string | ”Chat_Input” | The type of the command. |
[data.name] | string | The name of the command. | |
[data.name_localizations] | Object | The localizations of the command name. | |
[data.description] | string | The description of the command. | |
[data.description_localizations] | Object | The localizations of the command description. | |
[data.options] | Array.<Object> | The options of the command. | |
[data.default_member_permissions] | string | The default permissions of the command for members. | |
[data.dm_permission] | boolean | true | Whether the command can be used in DMs. |
slash.setType(type) ⇒ Slash
Sets the type of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
type | number | string | The type of the command. |
slash.setName(name) ⇒ Slash
Sets the name of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
name | string | The name of the command. |
slash.setDescriptionLocalizations(description) ⇒ Slash
Sets the description of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
description | string | The description of the command. |
slash.setNameLocalizations([localizations]) ⇒ Slash
Sets the localizations of the name of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
[localizations] | Object | The localizations of the command name. |
slash.setDescription(description) ⇒ Slash
Sets the description of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
description | string | The description of the command. |
slash.setDefaultMemberPermissions(…permission) ⇒ Slash
Sets the default member permissions of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
…permission | number | The permissions of the command for members. |
slash.setDmPermission(permission) ⇒ Slash
Sets whether the Slash Command can be used in DMs.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
permission | boolean | Whether the command can be used in DMs. |
slash.setOptions(fn) ⇒ Slash
Sets the options of the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
fn | Array.<Object> | function | The options of the command or a function that returns options. |
slash.addSubCommandGroups(fn) ⇒ Slash
Adds sub-command groups to the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
fn | Array.<Object> | function | The sub-command groups or a function that returns sub-command groups. |
slash.addSubCommands(fn) ⇒ Slash
Adds sub-commands to the Slash Command.
Kind: instance method of Slash
Returns: Slash
- The Slash instance.
Param | Type | Description |
---|---|---|
fn | Array.<Object> | function | The sub-commands or a function that returns sub-commands. |
slash.validation()
Validates the properties of the ApplicationCommand object.
Kind: instance method of Slash
Throws:
TypeError
If the Application Command Type is invalid or dmPermission is not a boolean.RangeError
If the context menu command has a description or options, or if the name or description length is invalid, or if the number of options exceeds 25.
slash.toJSON() ⇒ Object
Converts the ApplicationCommand object to JSON format.
Kind: instance method of Slash
Returns: Object
- The ApplicationCommand object in JSON format.
Throws:
TypeError
If the Application Command Type is invalid or dmPermission is not a boolean.RangeError
If the context menu command has a description or options, or if the name or description length is invalid, or if the number of options exceeds 25.