Skip to content

CommandBuilder

CommandBuilder is used to construct a command for a Discord application, including type, name, description, and options.

Usage:

local command = CommandBuilder.new()
:setType(CommandBuilder.Type.ChatInput)
:setName("example_command")
:setDescription("This is an example command.")
:setNSFW(false)
:setDMPermission(true)
:setDefaultPermissionEnabled(true)
:addOption(CommandOptionBuilder.new():setType(CommandOptionBuilder.Type.String):setName("option1"):setDescription("An option"))

Properties

Type

CommandBuilder.Type  :: table

An enumeration of command types.

  • ChatInput: 1
  • UserContextAction: 2
  • MessageContextAction: 3

Context

CommandBuilder.Context  :: table

An enumeration of command contexts.

  • Guild: 0
  • BotDM: 1
  • PrivateChannel: 2

IntegrationType

CommandBuilder.IntegrationType  :: table

An enumeration of command integration contexts.

  • GuildCommand: 0
  • UserCommand: 1

Methods

setType

CommandBuilder : setType (

     commandType: number
)  -> Builders.CommandBuilder

Sets the type of the command.

setLocalization

CommandBuilder : setLocalization (

     localizationCode: string
)  -> Builders.CommandBuilder

Sets the localization code for the command.

setDescription

CommandBuilder : setDescription (

     description: string
)  -> Builders.CommandBuilder

Sets the description of the command.

setName

CommandBuilder : setName (

     name: string
)  -> Builders.CommandBuilder

Sets the name of the command.

setNSFW

CommandBuilder : setNSFW (

     isNSFW: boolean
)  -> Builders.CommandBuilder

Sets whether the command is NSFW.

setGuildPermissions

CommandBuilder : setGuildPermissions (

     permissionObject: PermissionsBuilder
)  -> Builders.CommandBuilder

Sets the required permissions for the command in a guild.

addOption

CommandBuilder : addOption (

     commandObject: CommandOptionBuilder
)  -> Builders.CommandBuilder

Adds an option to the command.

addContext

CommandBuilder : addContext (

     context: number
)  -> Builders.CommandBuilder

Adds a context to the command.

addIntegration

CommandBuilder : addIntegration (

     integration: IntegrationType
)  -> Builders.CommandBuilder

Adds an intergration to the command.

toPayloadObject

CommandBuilder : toPayloadObject ()  -> Network.Resolvable

Converts the command to a JSON object that can be sent to the Discord API.

Functions

new

CommandBuilder . new ()  -> ()

Creates a new instance of CommandBuilder.