Create Command - Syrup/kurapika GitHub Wiki
Create Command
to create a command you have to do..
- Create category in
commands
folder - Create file javascript in
commands/category
folder example
commands
└── general
└── test.js
- Create a command code like this
const Discord = require("discord.js");
const { Command } = require("discord-akairo");
class TestCommand extends Command {
constructor() {
super("test", {
aliases: ["test"],
category: "Category",
description: {
content: "test command",
usage: "test",
example: ["test"]
}
})
}
exec(msg) {
return msg.channel.send("The test command was executed successfully")
}
}
module.exports = TestCommand;
Above is the most basic code for the test command. Let me explain...
Class NameCommand extends Command
- This is so that the system knows that there is a command in this fileconstructor()
- yeah this is constructorsuper("name", ...)
- it's for the command namealiases: ["name", "aliases"]
- In the aliases array at the very beginning you have to enter the name of the command, otherwise the command will not runcategory: "Category"
- This is the place where you assign categories to your commandsdescription: { content: "this is description", usage: "this is usage", example: ["this is example in array"] }
- This is the part where you describe your commandexec(msg, ...) { ... }
- This is the part where you create how to get your code runningmodule.exports = NameCommand
- This is the part where your file returns the command class