CommandBuilder class

const command = new CommandBuilder(data?: object);

constructor

The constructor provides one optional argument, which is an object which provides the data for the Command Builder.

The object may contain the following information:

  • name: The name of the command you want to create.

  • description: The description of the command you want to create.

  • options: An array with raw data of the command options which users can fill in in the slash command.

  • nsfw: A boolean which defines whether the command is NSFW or not.

  • dm_permission: Whether the command may be executed in a DM channel.

  • permissions: A bigint which defines a permission the user needs to execute the command, converted to a string.

  • overwrite: Whether to overwrite any existing commands with the same name.

ArgumentDescription

data

An object with the data to create the Command Builder from. The data which can be added is mentioned above.

Properties

name

The name of the command which was set with the setName function.

description

The description of the command which was set with the setDescription function.

options

An array with the options converted to an object to make it a valid Discord API object, that have been set with the addOptions function.

dm_permission

A boolean which defines whether the command should be available in the DM channel of the bot or not.

permissions

A permission that has been set with the setPermission function which defines the permission a user needs to execute the command.

nsfw

A boolean which defines whether the command should be marked as NSFW or not, which was set with the setNSFW function.

overwrite

A boolean which defines whether the command should overwrite any other existing commands with the same name, which was set with the setOverwrite function.

Functions

setName

commandBuilder.setName(name: string) : CommandBuilder;

Sets a name for the command and returns the same CommandBuilder class so you don't have to declare it everytime again. This is required to create a command.

ArgumentDescription

name

The name for the command you want to create. This must be a string between 1-32 characters.

setDescription

commandBuilder.setDescription(description: string) : CommandBuilder;

Sets a description for the command and returns the same CommandBuilder class so you don't have to declare it everytime again. This is required to create a command.

ArgumentDescription

description

The description you want to give to the command. This must be a string between 1-100 characters.

setCategory

commandBuilder.setCategory(category: string) : CommandBuilder;

Gives the command a category which will be used to display the command in the help embed. The function returns the same CommandBuilder class so you don't have to declare it everytime again. By not using this function, the command will by default get the General category.

ArgumentDescription

category

The category you'd like to give to the command you're creating. This must be one of the categories shown in the help embed of Zyno Bot.

setPermission

commandBuilder.setPermission(permission: permissionsBitfield) : CommandBuilder;

Sets a permission to the command so only users with the set permission can execute the command and returns the same CommandBuilder class so you don't have to declare it everytime again. See the permissionsBitfield page for the available permissions.

ArgumentDescription

permission

The permission the user needs to execute and view the command. The available permissions can be found here.

setNSFW

commandBuilder.setNSFW(nsfw?: boolean) : CommandBuilder;

Marks or unmarks the command as NSFW and returns the same CommandBuilder class so you don't have to declare it everytime again. If there aren't any arguments provided, the bot will automatically mark the command as NSFW. By setting the nsfw argument to false, it will unmark the command as nsfw.

ArgumentDescription

nsfw

A boolean which defines whether the command should be marked as NSFW or not.

setOverwrite

commandBuilder.setOverwrite(overwrite?: boolean) : CommandBuilder;

Changes the overwrite status of the command and returns the same CommandBuilder class so you don't have to declare it everytime again. The overwrite argument defines whether the command should overwrite any other existing commands with the same name. If there aren't any arguments provided, the bot will automatically overwrite any existing commands with the same name.

ArgumentDescription

overwrite

A boolean which defines whether any other commands with the same name should be overwritten or not.

addOptions

commandBuilder.addOptions(...options: [CommandOptionsBuilder]) : CommandBuilder;

Adds options to the command which users can fill in and returns the same CommandBuilder 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.

ArgumentDescription

options

An array or a row of CommandOptionsBuilder classes which define the options the users have for this command.

toJSON

commandBuilder.toJSON() : object;

Converts the CommandBuilder to an object to make it a valid object for the Discord API.

{
    name: string;
    description: string;
    options?: [object];
    dm_permission: boolean;
    default_member_permission?: string;
    nsfw: boolean;
    overwrite: boolean;
}

Last updated