DiscordFeaturesHandler Setup

Dive into the specifics details of each parameters and properties.

Usage

Here is a sample usage with the all properties and parameters.

const options = {
  mainDirectory: __dirname, // local path to your index.js file
  config: "./config.js", // configuration file
  commandDir: "commands", // commands folder name 
  eventDir: "events", // events folder name 
  modulesDir: "modules", // modules folder name
  BOT_TOKEN: "YOUR_BOT_TOKEN", // discord bot token
  disableBuiltIn = {
    allBuiltIn: false,  // disables all built-in commands and events
    commands: {
      help: false, // disables the built-in help command
      reload: false, // disables the built-in reload command
    },
    events: {
      messageCreate: false, // disables the built-in messageCreate event 
      interactionCreate: false, // disables the built-in interactionCreate event
      // disables the built-in ready event used to create slash commmands  
      loadSlashCommandsReady: false, 
    },
  },
  disableUnhandledRejectionHandler = false, // disable unhandledRejection handler
  modulesPreloadTime = 5000, // defines the wait time before loading modules files
  loadCommandsLoggerOff = false, // disable the log to show what commands has been loaded
  loadEventsLoggerOff = false, // disable the log to show what events has been loaded
  loadModulesLoggerOff = false, // disable the log to show what modules has been loaded
  // files in commands,event,or modules folder to exclude on load
  filesToExcludeInHandlers: {
    commands: [""],
    events: [""],
    moduless: [""],
  }, 
};

DiscordFeaturesHandler(client, options);

client

The constructor from discord.js client object.

You can refer to Discord.js documentation for more information

options

An options object that contains properties to configure DiscordFeaturesHandler how you want it and to get your discord.js bot up and running.

Properties

mainDirectory

The full path location to the script file

Type: string

Expected Value: __dirname

config

The path and filename to your config.js file. Please refer to config.js to see file setup and customization.

Type: ?string

commandDir

The folder name (not path to folder) that will contain your subfolders and no js files. In the sub-folders will be your command files

Type: string

eventDir

The folder name (not path to folder) that will contain your event js files.

Type: string

modulesDir

The folder name (not path to folder) that will contain your modules js files.

Type: string

BOT_TOKEN

This is your bot token that you can find in your Discord Developer Portal. This is required to login to your discord bot.

Type: string

disableBuiltIn

This object contains properties of true or false values of what built-in commands and events to disable

Type: object

disableUnhandledRejectionHandler

An Boolean to disable the pre-defined unhandledRejection function to handled uncaught promise rejection, in where bot would not crash upon reaching the rejection.

Recommend disabling only to use if you are re-creating this handler to print out the error tailored to read. Otherwise your bot may crash more often.

Type: Boolean

Default: false

modulesPreloadTime

The time to wait before loading modules files. This is used to establish a waiting time to connect to the Discord API and ensure we can access the guilds the bot has access to and their Discord Channels, users, guild information to use within the module files that are waiting to be loaded. The time value is in milliseconds, and by default the wait time is 5000 ms or 5 seconds before modules file is loaded. You can set the time based off if and how many file in the module folder require access to the Discord API.

Type: Number

Default: 5000

loadCommandsLoggerOff

An Boolean to disable the console.log for all command files that are being loaded. This is can be set if you do not want to see which files are loaded and only see the total count of command files loaded by the handler.

Any command file that fail to load will still show an error message in the console log when attempting to load from handler

Type: Boolean

Default: false

loadEventsLoggerOff

An Boolean to disable the console.log for all event files that are being loaded. This is can be set if you do not want to see which files are loaded and only see the total count of event files loaded by the handler.

Any event file that fail to load will still show an error message in the console log when attempting to load from handler

Type: Boolean

Default: false

loadModulesLoggerOff

An Boolean to disable the console.log for all module files that are being loaded. This is can be set if you do not want to see which files are loaded and only see the total count of module files loaded by the handler.

Any module file that fail to load will still show an error message in the console log when attempting to load from handler

Type: Boolean

Default: false

disableAllDefaults

DEPRECATED: disableAllDefaults deprecated. Use disableBuiltIn.allBuiltIn instead

This disable all default commands and events provided by DiscordFeaturesHandler on import.

Type: Boolean

Default: false

disableDefaultHelpCmd

DEPRECATED: disableDefaultHelpCmd deprecated. Use disableBuiltIn.commands.help instead

This disable all default help command file provided by DiscordFeaturesHandler on import.

Type: Boolean

Default: false

disableDefaultReloadCmd

DEPRECATED: disableDefaultReloadCmd deprecated. Use disableBuiltIn.commands.reload instead

This disable all default reload command file provided by DiscordFeaturesHandler on import.

Type: Boolean

Default: false

disableDefaultMessageCreate

DEPRECATED: disableDefaultMessageCreate deprecated. Use disableBuiltIn.events.messageCreate instead

This disable all default messageCreate event file, that handles executing commands and listen to commands call when prefix is used provided by DiscordFeaturesHandler on import.

Type: Boolean

Default: false

filesToExcludeInHandlers

An object that contains properties of handler name for the array of string. The strings of files that should not run when bot starts up

Type: Object

Properties

commands

The command files that should not run when handler is invoked

Type: Array<string>

events

The event files that should not run when handler is invoked

Type: Array<string>

modules

The module files that should not run when handler is invoked

Type: Array<string>

Last updated