Skip to content
On this page

CommandsManager

Create an handler for bot commands. The commands can be in as many subfolders as desired and there may be other files exporting something else.

Constructor

js
new CommandsManager(client, options);
NameTypeDescriptionDefaultOptional
clientShewenyClientThe clientNoneNo
optionsCommandsManagerOptionsOptions of the commands managerNoneNo
Properties
Methods
Events

Properties

applicationPermissions

If the application permissions is set.

Return : Boolean

autoRegisterApplicationCommands

If the application commands must be registered.

Return : Boolean

client

The framework client.

Return : ShewenyClient

commands

The loaded commands.

Return : Collection<Command>

default

The default data of the commands.

Return : CommandsManagerDefaultOption

directory

The directory of commands.

Return : String

guildId

The guild id(s) for registering commands.

Return String or Array<String>

prefix

The prefix for message commands

Return : String

Methods

[async] createCommand(command, guildId)

Create single command.

Parameters :

NameTypeDescriptionDefaultOptional
commandApplicationCommandThe command
guildIdStringThe guild to register command

Return : Promise<ApplicationCommand>

[async] deleteAllCommands( guildId)

Delete all commands.

Parameters :

NameTypeDescriptionDefaultOptional
guildIdStringThe guild to delete command

Return : Promise<Collection<Snowflake, ApplicationCommand>>

[async] deleteCommand(command, guildId)

Delete single command.

Parameters :

NameTypeDescriptionDefaultOptional
commandApplicationCommandResolvableThe command to delete
guildIdStringThe guild to delete command

Return : Promise<Collection<Snowflake, ApplicationCommand>>

[async] editCommand(oldCommand, newCommand, guildId)

Edit single command.

Parameters :

NameTypeDescriptionDefaultOptional
oldCommandApplicationCommandResolvableThe command to edit
newCommandApplicationCommandThe new command
guildIdStringThe guild to update command

Return : Promise<ApplicationCommand>

getApplicationCommandData()

Create an array with all commands data for register it.

Return : Array<ApplicationCommandData>| ApplicationCommandData | undefined

[async] loadAll()

Load all commands in collection.

Return : Promise<Collection<String, ApplicationCommand>>

[async] registerApplicationCommands(commands, guildId)

Register application commands.

Parameters :

NameTypeDescriptionDefaultOptional
commandsCollection<String, ApplicationCommand)>The commandsclient.collections.commands
guildIdStringThe guild to register commands

Return : Promise<Collection<Snowflake, ApplicationCommand>>

[async] registerPermissions(commands, guildId)

Register application commands.

Parameters :

NameTypeDescriptionDefaultOptional
applicationCommandsCollection<String, ApplicationCommand)>The application commandsclient.collections.commands
clientCommandsCollection<String, Command)>The client commandsclient.collections.commands
guildIdString or Array<String>The guild to register commands

Return : Promise<Collection<Snowflake, ApplicationCommand>>

unloadAll()

Unload all commands.

Return : void

Events

clientMissingPermissions

Emitted when client missing permissions.

Parameters :

NameTypeDescription
interactionCommandInteraction or ContextMenuInteractionThe interaction
missingArray<Permission>The name of missing permission
commandCommandThe command

cooldownLimit

Emitted when user hit the cooldown limit.

Parameters :

NameTypeDescription
interactionCommandInteraction or ContextMenuInteractionThe interaction
timeNumberThe time before run again

invalidChannel

Emitted when user try to use command in invalid channel.

Parameters :

NameTypeDescription
commandCommandThe command
interactionCommandInteraction or ContextMenuInteractionThe interaction

userMissingPermissions

Emitted when user missing permissions.

Parameters :

NameTypeDescription
interactionCommandInteraction or ContextMenuInteractionThe interaction
missingArray<Permission> or BOT_ADMINThe name of missing permission
commandCommandThe command