Quick Start

Here is a basic example of how to setup and configure discord-features-handler. When calling the constructor you can pass in the discord client object and regular object that configures discord-features-handler to how you want. Basic folder structure layout:

discord-bot/
├── commands/
│   ├── miscellaneous/   //this can be any name you want
│   │   └── ping.js
├── events/
│   └── ready.js
├── modules/
├── node_modules/
├── .env
├── config.js
├── index.js
├── package-lock.json
└── package.json

Here is a simple example with only the essentials to get a bot up and running:

index.js
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const { DiscordFeaturesHandler } = require("discord-features-handler");

const client = new Client({
 intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.DirectMessages,
  ],
  partials: [Partials.Channel, Partials.Channel],
});

DiscordFeaturesHandler(client, {
  config: "./config.js", // configuration file
  directories: {
    main: __dirname, // local path to your index.js file
  },
});

DiscordFeaturesHandler(client, options)

options properties

The object parameter should contain the follow keys. The value of the keys are based off the type stated below.

When setting up the bot you must always set this in property value: directories:{ main: __diranme } This set the local path to your index.js file. This is a requirement in order for this handler to run.

View DiscordFeaturesHandler Setup Page for more details

Create Commands

Follow the folder structure and create sub folders inside your command folder. Name these sub-folders as a category name for your command files. Afterwards, create the command files inside those sub-folders. All commands have the following:

execute(message, args, client, level)

View Commands Setup Page for more details

Creating Slash Commands

You will need to set the command properties mentioned above and the following:

View Slash Commands Setup Page for more details

Creating Events

Events file are created inside the event directory folder.

View Events Setup Page for more details

Creating Modules

These are your feature files and you can define anything you want in here and is an optional folder that you can use. If using JavaScript they are module.exports file and for TypeScript they are exports defauilt files. The only parameter is DiscordJS Client is that you can use if required for your feature.

If using TypeScript, create your modules file with exports default instead of module.exports.

module.exports = (client) => {
    // do something
};

Last updated