Skip to main content

Handlers

Load commands, events and interactions with Erine Loader.

Loading commands

Use CommandBuilder and GroupBuilder classes.

const { CommandBuilder, FileModule, GroupBuilder } = require("erine");

/** @type {FileModule[]} */
module.exports["data"] = [{
data: new CommandBuilder({
name: "ping",
description: "Sends pong."
})
code: async function(ctx) {
await ctx.send("PONG!");
}
},{
data: new GroupBuilder({
name: "bot",
description: "Bot commands."
})
.addCommand({
data: new CommandBuilder({
name: "info",
description: "Shows bot information."
}),
code: async function(ctx) {
// ... do something
}
})
}]

Loading events

You must use the EventBuilder class.

const { EventBuilder, Events } = require("erine");

const data = {
data: new EventBuilder({
name: Events.ClientReady,
code: async function(bot) {
console.log("Client started, name:", bot.user.username);
}
})
}

module.exports = { data };

Loading interactions

You must use InteractionBuilder class.

const { InteractionBuilder, Interactions } = require("erine");

const command = {
data: new InteractionBuilder({
name: "customID",
type: Interactions.Button
}),
code: async function(interaction) {
interaction.reply("Button reply.");
}
}

module.exports = { data: command };

All commands, events and interactions must be inside the folder declared in Erine#load.