Creating Commands
To create commands you must require/import the Maker class and Command decorator from erine and then extend the Maker class and put the command inside using the Command decorator.
Examples
Ping Command
const { Maker, Command } = require("erine");
class Ping extends Maker {
@Command({ name: "ping", aliases: ["latency"] })
async ping(context) {
await context.send("My ping is: ".concat(context.guild.shard.latency).toString());
}
}
module.exports = { data: Ping }; // Important to export the class as "data".
Getting Parameters
const { Maker, Command, Param, ParamType } = require("erine");
class Say extends Maker {
@Command({
name: "say",
aliases: ["repeat"],
description: "Repeats your message."
})
@Param(ParamType.String, {
name: "text",
description: "The text to say.",
required: true,
ellipsis: true // If enabled, retrieves all the user input.
})
async ping(context) {
const text = context.get("text"); // Getting the param.
await context.send(text);
}
}
module.exports = { data: Say }; // Important to export the class as "data".
Command Group
const { Command, Group, Maker } = require("erine");
class Bot extends Maker {
// USAGE: [prefix|slash]bot ping
@Group({ name: "bot", aliases: ["client"] })
@Command({
name: "ping",
aliases: ["latency"],
description: "Get the shard latency."
})
async ping(context) {
await context.send("My ping is: ".concat(context.guild.shard.latency).toString());
};
// USAGE: [prefix|slash]bot version
@Group({ name: "bot", aliases: ["client"] })
@Command({
name: "version",
description: "Check the NODE.JS version."
})
async v(context) {
await context.send(process.version);
}
}
module.exports = { data: Bot }; // Important to export the class as "data".