📄
Discord Features Handler Docs
  • discord-features-handler documentation
  • Getting Started
    • Quick Start
    • Environment Variables
    • DiscordFeaturesHandler Setup
  • Layout
    • Folder Structure
    • Setting up Commands
      • Setting up Slash Commands
      • Setting up other interactions
    • Setting up Events
  • Built-in
    • Disabling Built-in Commands and Events
    • Built-in Functions
    • Built-in config.js file
    • Built-in Customizable Commands
      • Built-in Help Command
      • Built-in Reload Command
    • Built-in Customizable Events
      • Built-in MessageCreate Event
      • Built-in interactionCreate Event
  • References
    • Roadmap
    • ChangeLog
Powered by GitBook
On this page
  • options properties
  • Create Commands
  • Creating Slash Commands
  • Creating Events
  • Creating Modules
  1. Getting Started

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.

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.

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

{...}

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

Creating Slash Commands

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

Property
Type
Required
Description

data

SlashCommandBuilder

true

slash command setup

interactionReply(interaction, client, level)

async Function

true

Creating Events

Events file are created inside the event directory folder.

Property
Type
Required
Description

name

string

true

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

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
};
Previousdiscord-features-handler documentationNextEnvironment Variables

Last updated 11 months ago

View Setup Page for more details

View Page for more details

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

View Page for more details

Discord Event Name. List of names can be found .

View Page for more details

DiscordFeaturesHandler
Commands Setup
Slash Commands Setup
Events Setup
Discord.Client
Message Object
Discord.Client
interaction
client
here