discoda
TypeScript icon, indicating that this package has built-in type declarations

1.1.9 • Public • Published

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

Installation

# npm
npm install discoda

# yarn
yarn add discoda

# pnpm
pnpm add discoda

Basic usage example

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.

Package Sidebar

Install

npm i discoda

Weekly Downloads

0

Version

1.1.9

License

MIT

Unpacked Size

74.2 kB

Total Files

109

Last publish

Collaborators

  • notpannh