Command initialization method
Some commands may require you to run code when they are loaded. You can use the init()
method within your command to handle this type of functionality:
typescript
import { Client } from 'discord.js'
import NYXBCommands, { CommandObject, CommandType } from '@nyxb/commands'
export default {
description: 'Ping pong command',
type: CommandType.BOTH,
init: (client: Client, instance: NYXBCommands) => {
console.log('Ping command has been loaded')
},
callback: () => {
return {
content: 'Pong!',
}
},
} as CommandObject
CommandsCorrect argument usageYou can specify the exact arguments and the minimum/maximum number of arguments for each command. If the user provides an incorrect number of arguments then NYXBCommands will automatically tell them the correct usage based off of the command properties you provided. Here is an example:CommandsBot owner only commandsSome commands should only be available to the bot owners. A perfect example of this is a "status" command that updates the status of your bot. NYXBCommands comes with this capability.