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 = {
  config = "./config.js",  // configuration file
  directories = {
    main: __dirname // local path to your index.js file
    commands: "commands", // commands folder name 
    events: "events", // events folder name 
    modules: "modules",  // modules folder name
  },
  builtin_files = { 
    disable_all: 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
    },
  },
  onLoad_list_files = {
    commands: false,  // disable the log to show what commands has been loaded
    events: false, // disable the log to show what events has been loaded
    modules: false, // disable the log to show what modules has been loaded
  },
  // disable unhandledRejection handler
  disableUnhandledRejectionHandler = false,
  // defines the wait time before loading modules files
  modulesPreloadTime = 5000,
  // files in commands,event,or modules folder to exclude on load
  filesToExcludeInHandlers = {
    commands: [""],
    events: [""],
    modules: [""],
  },

  mainDirectory: __dirname, // deprecated
  commandDir: "commands", // deprecated
  eventDir: "events", // deprecated
  modulesDir: "modules", // deprecated
  BOT_TOKEN: "YOUR_BOT_TOKEN", // deprecated; define in your .env file instead
  disableBuiltIn = {...}, // deprecated
  loadCommandsLoggerOff = false, // deprecated
  loadEventsLoggerOff = false, // deprecated
  loadModulesLoggerOff = false, // deprecated
 
};

DiscordFeaturesHandler(client, options);

client

The constructor from discord.js client object.

You can refer to Discord.js documentation for more information

DiscordFeaturesHandlerOptions

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

config

The path and filename to your config.js file. Please refer to config.js to see file setup and customization. If empty will use a default config file seen in config.js.

Type: ?string

directories

The object containing the folder names and main directory path. main property is required

Type: object

builtin_files

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

Type: object

onLoad_list_files

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 update the time if you required a longer wait time other APi related such as connecting to a database or 0 ms if not required.

Type: Number

Default: 5000

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