Creating Events

This page is a basic outline of how events should be created. Events, much like commands, each belong to their own file, in the events folder specified. The file must be named after the event it is handling. For example, ready.js and messageDelete.js for the ready and messageDelete events.

Code (messageUpdate example)

module.exports = (bot, config, oldmessage, newmessage) => {
    if(oldmessage.content !== newmessage.content) {
        console.log(`Message edited!\n${oldmessage.content}\n${newmessage.content}`);
    }
}

In each event file, you are only ever exporting a single function.

This function will always have at least two arguments - bot, the discord.js client in the context of the event, and config, a copy of the options supplied to the threecommands client.

You can have as many additional arguments here as there are in the event you are handling. For instance, the messageUpdate event which we are handling here as an example supports two arguments. We add these ourselves after the bot and config arguments.

Usage and Output

Whenever a message's content is edited, here is the output:

Console

Message Edited!
Old Content
New Content

results matching ""

    No results matching ""