Assistant-Bot / Lib

A framework designed for Deno and used for the Assistant discord bot.
https://discord.gg/Z9aBxxw9av
GNU General Public License v3.0
5 stars 0 forks source link

Assistant v3

Assistant v3 Library Source Code used in Assistant Bot.
This code is licensed under GNU General Public License v3.

What is AssistantLib?

AssistantLib is a powerful, extensible framework to create a bot quickly, and easily. This framework is currently being developed and will be used for Assistant Bot.

Why use AssistantLib?

Special Code Examples

Get a command directly from a message!

client.on('message', (msg: Message) => {
    const commandName = msg.getCommand("!");
});

Elegant collector syntax!

client.on('message', (msg: Message) => {
    const commandName = msg.getCommand("!");
    switch(commandName) {
        case 'collect': {
            const msgs = new MessageCollector(client, {limit: 10});
            // Asynchronously iterate over
            // incoming messages!
            for await (const message of msgs) {
                console.log("Got a message: " + message.toString());
            }
        }
    }
});

Complete client configuration!

const MAX_LIMIT = 1000;
const client = new Client({
    sharding: {
        useDiscord: false,
    },
    connection: {
        emitPayloads: false,
        autoReconnect: true,
        compress: false,
        maxReconnectTries: 1,
        maxResumeTries: 1,
        respectDiscordGateway: true,
        timeout: 1000
    },
    intents: Intents.all().parse(),
    cache: {
        limit: MAX_LIMIT,
    }
}, new RuntimeManager(MAX_LIMIT));

Use the advanced Command and Module API without writing any command handling code from scratch!

const client = new Client();

class AdminPermission extends Permission {
    public constructor() {
        super('generic.permission.admin', 100);
    }

    public can(msg: Message, member: Member) {
        return member.permissions.has('administrator');
    }
}

class AdminCommand extends Command {
    public constructor() {
        super('admin', 'generic.command.admin', 'An admin command!');
        this.permissions = [new AdminPermission()];
        this.aliases = ['adm', 'a']
    }

    public async onRun(client: Client, msg: Message, args: string[]) {
        msg.reply('An admin command!')
    }
}

const commandHandler = new CommandHandler(client, {prefix: "!"});
commandHandler.registerCommand(new AdminCommand());

client.on('messageCreate', async msg => {
  await commandHandler.processMessage(msg);
});

await client.connect();