-
Notifications
You must be signed in to change notification settings - Fork 1
7) Adding events
First create a file that ends with .js
extension located in the directory you specified in the config.json
's events.directory
property.
Now you can just add your in-file config and start coding!
This should be defined in your in-file config.
This will be used while registering the event.
Example event names: ready, guildMemberAdd
All events: https://discord.js.org/#/docs/discord.js/main/class/Client
This is an optional property and false
by default.
If you want your command to get triggered by using it adds this property.
This stops your command and can have limitless arguments which won't matter.
An array
that includes the arguments given to the event.
This is a NodeJS.Global.Event
instance which represents the current event. You can get in-file config properties using it: event.getConfigValue("name")
Normally you can register events like this:
client.on("eventName", (argument1, argument2, argument3) => {
});
Just like those argument1, argument2 and argument3 you can get arguments using args
variable.
Like this:
const [argument1, argument2, argument3] = args;
So if your event is voiceStateChange you can get the old state and new state like this:
const [oldState, newState] = args;
Argument names are up to you so you can use oSt
or something else for oldState
too!