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
new CommandsManager(client, options);
Name | Type | Description | Default | Optional |
---|---|---|---|---|
client | ShewenyClient | The client | None | No |
options | CommandsManagerOptions | Options of the commands manager | None | No |
Properties
Methods
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 :
Name | Type | Description | Default | Optional |
---|---|---|---|---|
command | ApplicationCommand | The command | ||
guildId | String | The guild to register command | ✓ |
Return : Promise<ApplicationCommand>
[async] deleteAllCommands( guildId)
Delete all commands.
Parameters :
Name | Type | Description | Default | Optional |
---|---|---|---|---|
guildId | String | The guild to delete command | ✓ |
Return : Promise<Collection<Snowflake, ApplicationCommand>>
[async] deleteCommand(command, guildId)
Delete single command.
Parameters :
Name | Type | Description | Default | Optional |
---|---|---|---|---|
command | ApplicationCommandResolvable | The command to delete | ||
guildId | String | The guild to delete command | ✓ |
Return : Promise<Collection<Snowflake, ApplicationCommand>>
[async] editCommand(oldCommand, newCommand, guildId)
Edit single command.
Parameters :
Name | Type | Description | Default | Optional |
---|---|---|---|---|
oldCommand | ApplicationCommandResolvable | The command to edit | ||
newCommand | ApplicationCommand | The new command | ||
guildId | String | The 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 :
Name | Type | Description | Default | Optional |
---|---|---|---|---|
commands | Collection<String, ApplicationCommand)> | The commands | client.collections.commands | ✓ |
guildId | String | The guild to register commands | ✓ |
Return : Promise<Collection<Snowflake, ApplicationCommand>>
[async] registerPermissions(commands, guildId)
Register application commands.
Parameters :
Name | Type | Description | Default | Optional |
---|---|---|---|---|
applicationCommands | Collection<String, ApplicationCommand)> | The application commands | client.collections.commands | ✓ |
clientCommands | Collection<String, Command)> | The client commands | client.collections.commands | ✓ |
guildId | String 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 :
Name | Type | Description |
---|---|---|
interaction | CommandInteraction or ContextMenuInteraction | The interaction |
missing | Array<Permission> | The name of missing permission |
command | Command | The command |
cooldownLimit
Emitted when user hit the cooldown limit.
Parameters :
Name | Type | Description |
---|---|---|
interaction | CommandInteraction or ContextMenuInteraction | The interaction |
time | Number | The time before run again |
invalidChannel
Emitted when user try to use command in invalid channel.
Parameters :
Name | Type | Description |
---|---|---|
command | Command | The command |
interaction | CommandInteraction or ContextMenuInteraction | The interaction |
userMissingPermissions
Emitted when user missing permissions.
Parameters :
Name | Type | Description |
---|---|---|
interaction | CommandInteraction or ContextMenuInteraction | The interaction |
missing | Array<Permission> or BOT_ADMIN | The name of missing permission |
command | Command | The command |