-
-
Save AlexzanderFlores/b60815cd8a586f166bb431239edc1161 to your computer and use it in GitHub Desktop.
Example of dynamic validations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is written in JS but the handler will still have TS support as expected | |
// CREATE YOUR OWN DYNAMIC VALIDATIONS: | |
// index.js | |
new WOKCommands({ | |
client, | |
commandsDir: path.join(__dirname, 'commands'), | |
events: { | |
dir: path.join(__dirname, 'events'), | |
// First specify the event | |
interactionCreate: { | |
// Then specify a dynamic validation function that returns a boolean | |
// This can be called anything you want | |
buttons: (interaction) => interaction.isButton() | |
}, | |
// First specify the event | |
messageCreate: { | |
// Then specify a dynamic validation function that returns a boolean | |
// This can be called anything you want | |
isHuman: (message) => !message.author.bot | |
} | |
}, | |
}) | |
// EXMAPLE FILE PATH: (IMPORTANT) | |
// ./events/interactionCreate/buttons/event-example.js | |
// The "buttons" folder is the direct parent of the JS file. So it will look for dynamic validation functions called "buttons" and will only run this function if that dynamic validation returned true. | |
module.exports = async (interaction, instance) => { | |
// The interaction is guaranteed to be a button interaction | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment