Command class

const command = new Command(data: Message | CommandInteraction, interaction: boolean, registeredCommandData: object, addonData: object);

constructor

The Command class requires four arguments. The first argument must be either an instance of the Discord.js Message class or an instance of the Discord.js CommandInteraction class which provides the data for the command. The second argument must be a boolean and defines whether the command is a slash command or a message command. The third argument must be an object and is the data which the Zyno Bot Addons module has saved from registering the command. The fourth argument must be an object and is the data which the Zyno Bot Addons module has saved from registering the addon.

Properties

name

The name of the command which was executed.

description

The description of the command which was executed.

slashCommand

A boolean which defines whether the command is a slash command or a message command.

member

An instance of the Member class and represents the member who executed the command.

memberId

The id of the member which executed the command.

created

An instance of the NodeJS built-in Date class which represents the time when the command was executed.

createdTimestamp

A number which represents the timestamp of when the command was executed.

guild

An instance of the Guild class which represents the guild where the command was executed in.

guildId

The id of the guild where the command was executed in.

channel

An instance of the TextChannel, VoiceChannel, StageChannel, DirectoryChannel, ForumChannel, ThreadChannel or DMChannel and represents the channel where the command was executed in.

message

When the command is a message command, the message property will be an instance of the Message class which represents the message command.

messageId

When the command is a message command, the messageId property will represent the id of the message which executed the command.

args

An array with the data provided by the member splitted at every space.

options

An instance of the Save class which provides the options the member provided in case the command is a slash command.

Functions

reply

command.reply(...content: [string, Embed, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, object]) : Promise<Message>;

Replies to the command. The function returns a Promise which returns an instance of the Message class once the reply has been sent.

The object of the reply may contain the following information:

  • content: A string of the content of the reply.

  • embeds: An array with the Embed class.

  • files: An array with a string which represents a file url or an object when uploading a file.

  • components: An array with the Discord.js ActionRowBuilder class.

The file object data may contain the following information:

  • name: The name of the file you want to upload

  • attachment: The path of the file you want to upload

  • description: The description of the file

isSlashCommand

command.isSlashCommand() : boolean;

Returns a boolean which defines whether the command is a slash command or not.

executeCommand

command.executeCommand(commandName: string, args?: [any]) : Promise<void>;

Executes another registered command based on the command executed by the member. The command can be a default Zyno Bot command or another command created by another addon.

Last updated