https://github.com/pannh/discoda
Discord.js framework to build your bot more efficiently with more focus on what really matters, rather than boilerplate code
https://github.com/pannh/discoda
bot discord discordjs framework handler library nodejs typescript
Last synced: 3 months ago
JSON representation
Discord.js framework to build your bot more efficiently with more focus on what really matters, rather than boilerplate code
- Host: GitHub
- URL: https://github.com/pannh/discoda
- Owner: PannH
- Created: 2024-01-15T16:04:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-02T21:37:42.000Z (over 1 year ago)
- Last Synced: 2025-02-16T15:51:25.716Z (4 months ago)
- Topics: bot, discord, discordjs, framework, handler, library, nodejs, typescript
- Language: TypeScript
- Homepage: https://pannh.github.io/discoda/
- Size: 280 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
# Discoda
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## Links
- [GitHub](https://github.com/PannH/discoda)
- [Documentation](https://pannh.github.io/discoda/)
- [npm](https://npmjs.com/package/discoda)
- [Developer's Discord](https://discord.com/users/667302589213310997) - \@pannh (in case you'd like help)
- [Discord.js Documentation](https://discordjs.dev/docs/packages/discord.js/14.14.1)## Installation
```shell
# npm
npm install discoda# yarn
yarn add discoda# pnpm
pnpm add discoda
```## Basic usage example
Initialize your client
```ts
// 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 JavaScriptHandle the `ready` event
```ts
// 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 JavaScriptCreate a `/ping` command
```ts
// 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.