Skip to main content

Group Builder

GroupBuilder is the class for creating groups of commands.

// Command builder constructor options.
type GroupBuilderOptions = {
name: string
aliases: string[];
description: string;
as_slash: boolean;
as_prefix: boolean;
}

// Command options
interface FileModule {
data: CommandBuilder | GroupBuilder | InteractionBuilder | EventBuilder,
params?: ParamsBuilder,
plugins?: typeof ErinePlugins[],
code?: (...args: any) => void
}

Example

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

/** @type {FileModule} */
const data = {
data: new GroupBuilder({
name: "parent",
description: "A packof subcommands.",
as_prefix: false,
as_slash: true
})
.addCommand({
data: new CommandBuilder({
name: "child-one",
description: "I'm the first command of this group."
}),
async code(context) {
await context.send(`My parent is ${context.parent.name}.`)
}
})
.addCommand({
data: new CommandBuilder({
name: "child-two",
description: "I'm the second command of this group."
}),
async code(context) {
await context.send(`My parent is ${context.parent.name}.`)
}
})
// Every .addCommand(...) represents a subcommand.
}

module.exports = { data } // Important to be named "data".