Dynamic Validations
Last updated
Last updated
This is a system to only run specific event files when a specific condition is met. For example you might only want to listen for the "messageCreate" event whenever a human sent a message and not a bot. You can use dynamic validations to achieve this without adding complexity to your code.
Here is how you setup dynamic validations:
The below dynamic validations are the default ones for WOKCommands. You do not need to implement these manually, but you can always add in your own.
As mentioned in the comments, you can specify a Discord.JS event name and a name for your dynamic validation. Your name can be anything, it doesn't have any correlation with Discord.JS method names at all.
The direct parent of your event files should match the dynamic validation name. In the example of a "log-messages" event file where we only want to log messages from humans and not bots:
The "isHuman" dynamic validation must return true for the "log-messages" event handler to be ran. As you can see from our index file, the "isHuman" method returns true or false depending on if the message author is a bot or a human.