Skip to content

Slash

Slash

A class representing a Discord Slash Command.

Kind: global class

new Slash([data])

ParamTypeDefaultDescription
[data]ObjectThe data for the Slash Command.
[data.type]number | string”Chat_Input”The type of the command.
[data.name]stringThe name of the command.
[data.name_localizations]ObjectThe localizations of the command name.
[data.description]stringThe description of the command.
[data.description_localizations]ObjectThe localizations of the command description.
[data.options]Array.<Object>The options of the command.
[data.default_member_permissions]stringThe default permissions of the command for members.
[data.dm_permission]booleantrueWhether 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.

ParamTypeDescription
typenumber | stringThe 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.

ParamTypeDescription
namestringThe 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.

ParamTypeDescription
descriptionstringThe 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.

ParamTypeDescription
[localizations]ObjectThe 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.

ParamTypeDescription
descriptionstringThe 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.

ParamTypeDescription
…permissionnumberThe 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.

ParamTypeDescription
permissionbooleanWhether 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.

ParamTypeDescription
fnArray.<Object> | functionThe 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.

ParamTypeDescription
fnArray.<Object> | functionThe 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.

ParamTypeDescription
fnArray.<Object> | functionThe 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.