Aidyn: Discord Bot Framework

1.1.1 · active · verified Sun Apr 19

Aidyn is a lightweight, class-based framework designed for rapidly building Discord bot commands, abstracting away much of the boilerplate associated with `discord.js` interaction. It is currently at version 1.1.1, indicating a relatively early but stable stage of development. While no explicit release cadence is stated, its versioning suggests a focused development approach. Key differentiators include its class-based command architecture, native TypeScript support (as the project is built in TypeScript), built-in state management for data handling between commands, and an integrated feature for automatic database backup specifically with MongoDB. It aims to let developers jump straight to business logic for their bot commands, providing a structured approach on top of `discord.js`.

Common errors

Warnings

Install

Imports

Quickstart

Initializes and starts a Discord bot using Aidyn, defining a simple command that responds with processed message content. This example demonstrates class-based command creation and bot setup with environment variables for credentials.

import { Aidyn, Command } from 'aidyn';
import { Message } from 'discord.js'; // Assuming discord.js is installed

class ExampleCommand extends Command {
    static NAME = 'example';

    public Name(): string {
        return ExampleCommand.NAME;
    }
    public Namespace(): string {
        return 'ExampleNamespace';
    }

    public async Run(message: Message): Promise<any> {
        const context = this.GetContext(message); // Process message content for args/flags

        return message.channel.send(`Command: %example was called with content ${JSON.stringify(context)}`);
    }
}

const commands: { [key: string]: typeof Command } = {};
commands[ExampleCommand.NAME] = ExampleCommand;

// Ensure you have these environment variables set
const botToken = process.env.DISCORD_BOT_TOKEN ?? 'YOUR_BOT_TOKEN_HERE';
const mongoConnectionString = process.env.MONGO_CONNECTION_STRING ?? '';

const aidyn = new Aidyn({
    Prefix: '%',
    ConnectionString: mongoConnectionString, // Required for database features (MongoDB only)
    BotToken: botToken,
    Logging: 1 // Log commands. Use 0 for no logging, 2 for verbose (not recommended)
});

aidyn.start(commands);
console.log('Aidyn bot started with example command!');

view raw JSON →