Skip to main content

Command Builder

CommandBuilder is the class for creating commands.

Interfaces

// Command builder constructor options.
interface CommandDataBuilder {
name: string
aliases?: string[]
description?: string
as_prefix?: boolean
as_slash?: boolean
fallback?: true
}

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

Example

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

/** @type {FileModule} */
const data = {
data: new CommandBuilder({
name: "mention",
description: "Mentions a user.",
as_slash: true,
as_prefix: true
}),
params: new ParamsBuilder()
.addMember({ name: 'member', description: 'The member', required: true }),
async code(context) {
const member = context.get('member');
await context.send({
content: `<@${member.user.id}> hi`
});
}
}

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