Skip to content

discord-handler-js is an optimized Discord bot structure that lets you easily create your own Discord Bot.

License

Notifications You must be signed in to change notification settings

agonkolgeci/discord-handler-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-handler-js v14 🤖

discord-handler-js is an optimized Discord bot structure that lets you easily create your own Discord Bot.

Further information

Table of contents 📃

Requirements

Environnement

Prelude

Installation

Please read Requirements before starting installation.

  1. Install this project (2 options):

  2. Open the new folder with your favorite text editor

  3. Configure the following files:

    • .env - Application Credentials
    • src/resources/config.js - Client Configuration
  4. Install required packages:

npm install
  1. Run your bot in normal mode: (otherwise see sharding mode)
node src/index.js

Application Sharding

To run your application in sharding mode:

node src/shard.js

Application Commands

Slash commands / User and Message contexts

You can implement various commands in the same file.

export default [
    {
        structure: SlashCommandBuilder | ContextMenuCommandBuilder,
      
        onCommand: async(client, interaction) => {
            await interaction.reply(`Command ${interaction.commandName} used by ${interaction.user} !`);
        }
    },

    ... // More commands
]

Application Components

Buttons / Modals / Selects Menus

You can implement various components in the same file.

export default [
    {
        customId: string,

        onButton: async(client, interaction) => {
            await interaction.reply(`Button ${interaction.customId} used by ${interaction.user} !`);
        },
      
        onModalSubmit: async(client, interaction) => {
            await interaction.reply(`Modal ${interaction.customId} submited by ${interaction.user} !`);
        },

        onSelectMenu: async(client, interaction) => {
            await interaction.reply(`Select Menu ${interaction.customId} used by ${interaction.user} !`);
        }
    },

    ... // More components
]

Application Events

You can implement various events in the same file.

Note that you must replace ...args with the event arguments.

export default [
    {
        name: string,
        once: true,
      
        onEvent: async(client, ...args) => {
            await client.logger.log("info", `Event ${name} called !`);
        }
    },

    ... // More events
]

Custom Logger

discord-handler-js uses a custom logger system (using colors thanks to chalk).

You can configure it from the Logger Module

  • Import the Logger Module: import logger from "path/to/logger.js";

Client Message Formatter

discord-handler-js uses a message formatting system intended for users.

You can configure it from the configuration

  • Use from Extended Client ExtendedClient#formatter

MongoDB (Optional)

discord-handler-js lets you open a connection to a MongoDB.

Licence

This project is published under the GNU General Public License v^3.0. You can download, modify or redistribute - even commercially - this software freely, as long as you specify that your work is a reworking of this project. For more details, please refer to the license text.

Credits