A simple framework made for building discord bots with discord.js.
$ npm install @guardbot/framework # via npm
$ yarn add @guardbot/framework # yarn
$ pnpm add @guardbot/framework # pnpm- Easy to use.
- Beginner friendly.
- Supports Intellisense.
Create your main entry file (e.g., index.ts) and initialize the FrameworkClient.
import { FrameworkClient } from '@guardbot/framework';
import { GatewayIntentBits } from 'discord.js';
import path from 'path';
const client = new FrameworkClient({
clientOptions: {
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
},
rootDir: path.join(__dirname),
registerOnStart: true,
prefix: '!',
});
client.login('DISCORD_BOT_TOKEN');Create a file in your commands directory (e.g., src/commands/general/ping.ts).
import { SlashCommand } from '@guardbot/framework';
export default SlashCommand({
name: 'ping',
description: 'Replies with Pong!',
commandScope: 'default',
cooldown: 5000,
async execute(client, interaction) {
await interaction.reply({ content: `Pong! 🏓 (${client.ws.ping}ms)` });
},
});Create a file for prefix-based commands (e.g., src/commands/general/ping.ts).
import { MessageCommand } from '@guardbot/framework';
export default MessageCommand({
name: 'ping',
description: 'Replies with Pong!',
aliases: ['latency'],
cooldown: 5000,
async execute(client, message, args) {
await message.reply({ content: `Pong! 🏓 (${client.ws.ping}ms)` });
},
});Create an event file (e.g., src/listeners/client/ready.ts).
import { Listener } from '@guardbot/framework';
export default Listener({
name: 'clientReady',
once: true,
async execute(client) {
console.log(`Logged in as ${client.user.tag}!`);
console.log(`Loaded ${client.commands.size} commands.`);
return true;
}
})