> For the complete documentation index, see [llms.txt](https://bng94.gitbook.io/discord-features-handler-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bng94.gitbook.io/discord-features-handler-docs/getting-started/discordfeatureshandler-setup.md).

# DiscordFeaturesHandler Setup

## Usage

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

<pre class="language-csharp"><code class="lang-csharp">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,
<strong>  // files in commands,event,or modules folder to exclude on load
</strong>  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);
</code></pre>

## client

The constructor from discord.js client object.

<table><thead><tr><th width="150">PARAMETER</th><th width="249.33333333333331">TYPE</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>client</td><td>Discord.js BaseClient Object</td><td>default client object from discord.js</td></tr></tbody></table>

You can refer to [Discord.js documentation](https://discord.js.org/#/docs/discord.js/stable/class/Client) 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](https://github.com/bng94/discord-features-handler-docs/blob/master/built-in/config-file.md) to see file setup and customization. If empty will use a default config file seen in [config.js](https://github.com/bng94/discord-features-handler-docs/blob/master/built-in/config-file.md).

**Type: ?string**

### directories

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

Type: object

<table><thead><tr><th width="152">Properties</th><th width="123">Type</th><th width="113">Required</th><th>Description</th></tr></thead><tbody><tr><td>main</td><td>string</td><td>true</td><td>The full path location to the script file<br>Expected value: __dirname</td></tr><tr><td>commands</td><td>string</td><td>false</td><td>Folder name that contains your command files. Default: "commands"</td></tr><tr><td>events</td><td>string</td><td>false</td><td>Folder name that contains your event files.<br>Default: "events"</td></tr><tr><td>modules</td><td>string</td><td>false</td><td>Folder name that contains your modules files.<br>Default: "modules"</td></tr></tbody></table>

### builtin\_files

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

**Type: object**

<table><thead><tr><th width="166">Properties</th><th width="150" align="center">Type</th><th width="110" align="center">Default</th><th>Description</th></tr></thead><tbody><tr><td>disable_all</td><td align="center">boolean</td><td align="center">false</td><td>Disables all built-in commands and events</td></tr><tr><td>commands</td><td align="center">Object</td><td align="center">{ ... }</td><td>Object contains the name of all built-in commands, that you may want to disable. Commands: help and reload</td></tr><tr><td>events</td><td align="center">Object</td><td align="center">{ ... }</td><td>Object contains names of all built-in events that you may want to disable. Events: messageCreate, interactionCreate</td></tr></tbody></table>

### onLoad\_list\_files

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

**Type: object**

<table><thead><tr><th width="166">Properties</th><th width="150" align="center">Type</th><th width="110" align="center">Default</th><th>Description</th></tr></thead><tbody><tr><td>commands</td><td align="center">boolean</td><td align="center">false</td><td>Enable console log of command being files loaded</td></tr><tr><td>events</td><td align="center">boolean</td><td align="center">false</td><td>Enable console log of event files being loaded</td></tr><tr><td>modules</td><td align="center">Object</td><td align="center">false</td><td>Enable console log of module files being loaded</td></tr></tbody></table>

### 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.

{% hint style="warning" %}
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.
{% endhint %}

**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**

<details>

<summary><strong>Properties</strong></summary>

**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>**

</details>
