0.1.5 • Published 8 years ago
chocolate-dbfw v0.1.5
Chocolate discord bot framework
One of MANY discord bot frameworks.
Take a look at the github examples
folder for more information.
Basic Setup
// Import the needed Classes from the framework
import { Client } from 'chocolate-dbfw';
import * as path from 'path';
// Define and apply options to client (there are lots more)
const client = new Client({
// Command prefix - this will be '!' if not set
commandPrefix: '!',
// Command directory - only required option
commandDirectory: path.join(__dirname, 'commands'),
});
// Set command groups for CommandRegistry
client.setCommandGroups([
['util', 'Utility Commands']
]);
client.runAll(); // Run all event listeners and loaders
client.start('token-here'); // Login
Example Command
import { Message } from 'discord.js';
import { Command, Client } from 'chocolate-dbfw';
export default class extends Command {
public constructor() {
super({
name: 'ping', // Name of the command
group: 'util', // What group the command belongs to.
});
}
// The function that will be executed when the command is called.
public execute(client: Client, message: Message) {
message.channel.send('Pinging...')
.then((msg: Message) => {
msg.edit(`:ping_pong: Pong! Took: \`${msg.createdTimestamp - message.createdTimestamp}ms\``);
});
}
}