To add commands, you will need to use the builders, which are included in the Zyno Bot addons library. To build the command itself, you will need to use the CommandBuilder class. This builder allows you to easily create a command. The builder creates a structure for the command and will make the bot able to communicate that structure to the Discord API to create the command.
An example of a command is:
constaddons=require('zyno-bot-addons');constmyAddon=newaddons.Addon({ // Create a new addon name:'My new addon',// The name of your addon description:'Creates a ping command',// A small description of what your addon does author:'Luuk',// Your (user)name so the owner of the copy knows who created the addon version:'1.0.0',// The version of your addon bitfield: [addons.bitfield.COMMANDS] // The permissions your addon needs});constcommandBuilder=newaddons.CommandBuilder() // Creates a new command.setName('hello') // Sets the name of the command to 'hello'.setDescription('Greets you back'); // Sets the description of the commandmyAddon.once('ready', () => {myAddon.createCommand(commandBuilder).then(cmd => {// The command was succesfully createdcmd.on('execute', command => { // When a user executes the commandcommand.reply('Hello!').catch(err => { // Replies with the text 'Hello'// An error occured while trying to reply to the commandconsole.log(`There was an error while replying to the command:`, err); }); }); }).catch(err => {// An error occured while creating the commandconsole.log(`There was an error while creating the command:`, err); });});
This is an example of how you can create new command. The command will be created when the addon is enabled by the owner of the bot and the bot has completed the regular start-up configuration.
After you've built the CommandBuilder, you need to add the command to the bot by using the createCommand function of the Addon class. The argument must be the CommandBuilder class. This will return a Promise which will return a CommandHandler once the command was created.