📄
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
  1. Built-in

Built-in Functions

For async/await, we can use this to pause the bot and handle certain events before proceeding.

  // `await client.wait(1000);` to "pause" for 1 second.
  client.wait = require("util").promisify(setTimeout);

A built-in Capitalization String Function for words in a sentence format.

  // <String>.toProperCase() returns a proper-cased string such as:
  // "A quick brown fox jumps the lazy dog".toProperCase()
  // returns "A Quick Brown Fox Jumps The Lazy Dog"
  String.prototype.toProperCase = function () {
    return this.replace(/([^\W_]+[^\s-]*) */g, function (txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });
  };

A built-in Array.random() function to return a random element of an Array

  Array.prototype.random = function () {
    return this[Math.floor(Math.random() * this.length)];
  };

Handling unhandledRejection, events that fails because of missing .catch(e => {...}); to prevent bot from crashing in middle of production.

  process.on("unhandledRejection", (e) => {
    console.log(e);
  });
PreviousDisabling Built-in Commands and EventsNextBuilt-in config.js file

Last updated 1 year ago