Discord.js framework to build your bot more efficiently with more focus on what really matters, rather than boilerplate code.
Made in TypeScript, for TypeScript
- GitHub
- Documentation
- npm
- Developer's Discord - @pannh (in case you'd like help)
- Discord.js Documentation
# npm
npm install discoda
# yarn
yarn add discoda
# pnpm
pnpm add discoda
Initialize your client
// File: src/index.ts
import { Client } from 'discoda';
// See more: https://pannh.github.io/discoda/classes/Client.html
const client = new Client({
intents: [
'Guilds',
'GuildMembers',
'GuildMessages',
'MessageContent'
],
handlerPaths: {
events: 'src/events',
slashCommands: 'src/commands'
}
});
client.login('YOUR_CLIENT_TOKEN');
The code above is written in TypeScript, adapt it if you code in JavaScript
Handle the ready
event
// File: src/events/ready.ts
import { Event } from 'discoda';
// See more: https://pannh.github.io/discoda/classes/Event.html
export default new Event({
name: 'ready',
triggerOnce: true
}, (client) => {
console.log('Client is ready to use');
// This will register all handled commands to Discord (here: slash commands)
client.registerCommands()
.then(() => console.log('Registered commands'))
.catch(() => console.error('Failed to register commands'))
});
The code above is written in TypeScript, adapt it if you code in JavaScript
Create a /ping
command
// File: src/commands/ping.ts
import { SlashCommand } from 'discoda';
// See more: https://pannh.github.io/discoda/classes/SlashCommand.html
export default new SlashCommand({
data: {
name: 'ping',
description: 'Shows the bot latency'
}
}, (client, interaction) => {
interaction.reply(`Pong! ${client.ws.ping}ms`);
});
The code above is written in TypeScript, adapt it if you code in JavaScript
🎉 Done! In only 3 files, you already have a fully working bot with handlers for events and slash commands.