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)

Properties
Type
Required

client

true

options

Object

true

options properties

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

Properties
Type
Required
Default

directories.main

folder path

true

null

config

path to config file

true

"./config"

directories.commands

String

false

commands

directories.events

String

false

events

directories.modules

String

false

modules

builtin_files

Object

false

{...}

filesToExcludeInHandlers

Object

false

{...}

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:

Property
Type
Required
Description

name

string

true

name of command

description

string

true

description of command

aliases

Array<string>

true

aliases of the command, you must set []

guildOnly

boolean

false

if command is guild only (not a DM command)

permission

Number

true

Permission level required to use command

minArgs

Number

true

Minimum number of arguments required for command execution

maxArgs

Number

false

Maximum number of arguments required for command execution

usage

string

true

Show how to use the command call

execute(message, args, client, level)

Function

true

Functionality and response of the command call

execute(message, args, client, level)

Property
Type
Required

message

true

args

Array<string>

false

client

false

level

User's Permission Level

false

View Commands Setup Page for more details

Creating Slash Commands

Property
Type
Required
Description

data

SlashCommandBuilder

true

slash command setup

interactionReply(interaction, client, level)

async Function

true

Functionality and response of the slash command call. Arguments are interaction, client, and user's permission level

View Slash Commands Setup Page for more details

Creating Events

Events file are created inside the event directory folder.

Property
Type
Required
Description

name

string

true

Discord Event Name. List of names can be found here.

once

boolean

false

if you want the event to run once on first trigger

execute(client, params...)

Function

true

functionality and response when the event is triggered

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.

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

Last updated