📄
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
  • Properties
  1. Layout

Setting up Events

PreviousSetting up other interactionsNextDisabling Built-in Commands and Events

Last updated 1 year ago

A simple way to setup your discord.js events. All you need to do is set the property name as the event name, and then pass in the parameters needed for the events in the execute function, and set up the rest of the events functionality in it. You can name the event.js file as anything you want. Here is a sample ready event in which I will name it readyEvent.js:

readyEvent.js
module.exports = {
    name: "ready", // name of the discord.js event
    once: true, // if this event should run once only
    async execute(client) { // when the event is invoked we execute this function
      console.log(`${client.user.tag}`,"Ready!");
    },
  };

Properties

name

This is the name of the discord client event. You can find the full list of discord event names in the

Type: String

once

If this discord event should run once or whenever it is called. You would only need this property if you are using the ready event or creating a slash event.

Type: Boolean

async execute(client, ...args)

This is the method used to execute and handle the discord event trigger. The first argument is always the . The following arguments must be the parameters from the event that you trying to trigger. For example, if the event is the , then the execute arguments would look like this:

It is optional to make the execute function, an asynchronous function

execute(client, oldMember, newMember) { 
    // do something
},

returns;

official Discord.js Documentation - Client Constructor
Discord Client object
guildMemberUpdate