1.2.11 • Published 2 years ago

burgerclient v1.2.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

BurgerClient

Burger Client is a simple command handler for Discord.js

Features

  • Object Oriented
  • Written in TypeScript
  • Command Handler
  • Full Typescript & Javascript support

Installation

Node.js 16.9.0 or newer is requried.

Burger Client depends on these dependencies:

npm

npm i burgerclient

Usage

JavaScript

const client = new BurgerClient({ typescript: false, // Whether or not your project is made in typescript intents: GatewayIntentsBits.Guilds, // Put your intents here partials: [], // Put your partials here testGuild: '1234567890', // Test guild ID for commands with the type: 'GUILD' property logInfo: true, // Whether or not to log info logs (enabled by default) mongoURI: 'myURIHere', // URI for connecting to MongoDB, if supplied });

// Listener to when the client is ready and the database has been connected to client.onReady(async discordClient => { client.registerAllCommands(path.resolve('commands')); // Registers all commands in the directory ./commands // Instead of registering all commands in a directory, you can also register a specific command in a file // client.registerCommand(require('./commands/ping'), 'ping');

await client.updateCommands();    // Updates all application commands
await client.updatePermissions(); // Updates all application command permissions

console.log(`Ready! Logged in as ${discordClient.user.tag}`);

});

// Listener when a user creates an interaction client.on('interactionCreate', interaction => { if (!interaction.isChatInputCommand()) return; // Checks if the command is a slash (/) command

client.resolveCommand(interaction); // Executes the command

});

client.login('myTokenHere'); // Logins to Discord using your bot's token

</details>

<details>
<summary>commands/ping.js</summary>

```javascript
const { ICommand } = require('burgerclient');
const { SlashCommandBuilder } = require('discord.js');

// For intellisense and auto-completions
/**
 * @type {ICommand}
 */
module.exports = {
  data: new SlashCommandBuilder()
    .setName('ping')
    .setDescription('Replies with pong!'),

  type: 'GUILD', // Command type can be either GUILD or GLOBAL
  
  // Optional permissions
  permissions: {
    default: 'SendMessages', // Default member permissions (only users with a specific permission can use this command)
    DMs: true,               // Whether or not this command is enabled in DMs (enabled by default)
  },

  listeners: {
    // Gets called when the command is executed
    onExecute: async ({ interaction }) => {
      interaction.reply('Pong!');
    },
    
    // Optional `onError` listener that gets called when an unexpected error gets thrown while executing the command
    onError: ({ error, interaction }) => {
      interaction.reply(`Uh oh, an error occurred! ${error.message}`);
    },
  },
};

TypeScript

const client = new BurgerClient({ typescript: true, // Whether or not your project is made in typescript intents: GatewayIntentsBits.Guilds, // Put your intents here partials: [], // Put your partials here testGuild: '1234567890', // Test guild ID for commands with the type: 'GUILD' property logInfo: true, // Whether or not to log info logs (enabled by default) mongoURI: 'myURIHere', // URI for connecting to MongoDB, if supplied });

// Listener to when the client is ready and the database has been connected to client.onReady(async discordClient => { client.registerAllCommands(path.resolve('commands')); // Registers all commands in a given directory // Instead of registering all commands in a directory, you can also register a specific command in a file // client.registerCommand(require('./commands/ping'), 'ping');

await client.updateCommands();    // Updates all application commands
await client.updatePermissions(); // Updates all application command permissions

console.log(`Ready! Logged in as ${discordClient.user.tag}`);

});

// Listener when a user creates an interaction client.on('interactionCreate', interaction => { if (!interaction.isChatInputCommand()) return; // Checks if the command is a slash (/) command

client.resolveCommand(interaction); // Executes the command

});

client.login('myTokenHere'); // Logins to Discord using your bot's token

</details>

<details>
<summary>commands/ping.ts</summary>

```typescript
import { ICommand } from 'burgerclient';
import { SlashCommandBuilder } from 'discord.js';

module.exports = {
  data: new SlashCommandBuilder()
    .setName('ping')
    .setDescription('Replies with pong!'),

  type: 'GUILD', // Command type can be either GUILD or GLOBAL
  
  // Optional permissions
  permissions: {
    default: 'SendMessages', // Default member permissions (only users with a specific permission can use this command)
    DMs: true,               // Whether or not this command is enabled in DMs (enabled by default)
  },

  listeners: {
    // Gets called when the command is executed
    onExecute: async ({ interaction }) => {
      interaction.reply('Pong!');
    },
    
    // Optional `onError` listener that gets called when an unexpected error gets thrown while executing the command
    onError: ({ error, interaction }) => {
      interaction.reply(`Uh oh, an error occured! ${error.message}`);
    },
  },
} as ICommand;

Contributing

Fork this project

Create an issue

Create a pull request

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.25

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago