Events

You can listen for all the events of discord.js API using this package.

The Basic Syntax :

module.exports = {
    name : 'name-of-the-event',
    async run(...parameters){
        \\ YOUR CODE
    }
}

Example : Let us test out the 'messageCreate' event. It gets emitted when a new message is created in a DM or a guild.

module.exports = {
    name : 'messageCreate',
    async run(message){ \\ Since this event emits message attribute.
        console.log(`<@${message.author.id}> said : ${message.content}`)
    }
}

This function will run whenever a new message is created.

Last updated