Eris Command Framework

3.0.0 · deprecated · verified Tue Apr 21

The Eris Command Framework (version 3.0.0) is a library designed to streamline the creation of command-based bots for the Eris Discord API library. It facilitates defining commands and plugins using TypeScript decorators (`@Command()`) and relies heavily on `reflect-metadata`, `TypeORM` for database interactions, and `Inversify` for dependency injection. The framework's architecture centers around `PluginInterface` and `CommandInterface` concepts. While functional, the project's README explicitly advises users to transition to Eris's native slash commands, indicating that this framework is no longer the recommended or actively developed approach for modern Eris bot development. As such, its release cadence is likely slow or halted, and users should consider alternatives for new projects. Its reliance on specific versions of TypeORM and Inversify can also lead to compatibility challenges with newer versions of those libraries or Eris itself.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Eris Command Framework with a basic Eris bot, configure TypeORM for an in-memory SQLite database, and register a simple 'ping' command within a plugin, showcasing decorator usage and framework setup. It includes necessary imports and minimal Discord bot boilerplate.

import { CommandFramework, Interfaces, types, Command } from 'eris-command-framework';
import { Client, Message } from 'eris';
import { Container } from 'inversify';
import { createConnection, Connection, Entity, PrimaryColumn, Column } from 'typeorm';
import 'reflect-metadata'; // Must be imported once at the top level

const token = process.env.DISCORD_BOT_TOKEN ?? 'YOUR_DISCORD_BOT_TOKEN';

// --- Dummy TypeORM Entity ---
@Entity()
class MyBotEntity {
    @PrimaryColumn()
    id!: string;

    @Column()
    value!: string;
}

// --- Example Plugin and Command ---
@Command({
    name: 'ping',
    category: 'General',
    description: 'Responds with pong!',
    args: []
})
class PingCommand implements Interfaces.CommandInterface {
    name: string = 'ping';

    async run(message: Message, _args: string[]): Promise<any> {
        await message.channel.createMessage('Pong!');
    }
}

class MyPlugin implements Interfaces.PluginInterface {
    name: string = 'MyPlugin';
    commands: Interfaces.CommandInterface[] = [
        new PingCommand()
    ];
    // You might inject dependencies here using Inversify
    constructor() {}
}

async function bootstrap() {
    const client = new Client(token);
    const container = new Container({ defaultScope: 'singleton' });

    const commandFramework = new CommandFramework(container, { prefix: '|' }); // Prefix is required

    const connection: Connection = await createConnection(
        {
            type: 'sqlite',
            database: ':memory:', // Use in-memory for quick demo
            synchronize: true,
            entities: [
                MyBotEntity,
                ...commandFramework.GetEntities() // Include framework's internal entities
            ]
        }
    );

    container.bind<Connection>(types.Connection).toConstantValue(connection);

    const plugins: Interfaces.PluginInterface[] = [
        new MyPlugin() // Your array of PluginInterfaces
    ];

    await commandFramework.Initialize(plugins);

    client.on('ready', () => {
        console.log('Bot is ready and connected!');
    });

    client.on('messageCreate', async (message: Message) => {
        // Check if the message starts with the command prefix
        if (message.author.bot || !message.content.startsWith(commandFramework.getOptions().prefix)) {
            return;
        }
        await commandFramework.Handle(message);
    });

    client.on('error', (err: Error) => console.error('Eris client error:', err));
    client.connect().catch(console.error);

    console.log('Bot is attempting to connect to Discord...');
}

bootstrap().catch(console.error);

view raw JSON →