This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Create Command
Syrup edited this page Feb 2, 2021
·
2 revisions
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 file -
constructor()
- yeah this is constructor -
super("name", ...)
- it's for the command name -
aliases: ["name", "aliases"]
- In the aliases array at the very beginning you have to enter the name of the command, otherwise the command will not run -
category: "Category"
- This is the place where you assign categories to your commands -
description: { content: "this is description", usage: "this is usage", example: ["this is example in array"] }
- This is the part where you describe your command -
exec(msg, ...) { ... }
- This is the part where you create how to get your code running -
module.exports = NameCommand
- This is the part where your file returns the command class