WOKCommands
  • WOKCommands Documentation
  • Useful Links
    • Setup & Options object
    • 🧠 Build a website dashboard, monetize your bot, and get more users
    • 💰 $100 in FREE Hosting Credits
    • 🙋‍♂️ Support Server
    • 📺 YouTube Channel
  • Commands
    • Ping pong command example
    • Command properties
    • Correct argument usage
    • Command initialization method
    • Bot owner only commands
    • Test servers
    • Cooldowns
    • Required permissions
    • Slash commands
    • Inferred slash command arguments
    • Custom slash command arguments
    • Autocomplete
  • Command Validations
    • Validation setup
    • Runtime validations
    • Syntax validations
  • Event Handler
    • Event Handling
    • Dynamic Validations
  • Features
    • Features
  • Built-in commands and features
    • Enabling and disabling commands
    • Configurable required roles
    • Configurable required permissions
    • Per-guild prefixes
    • Customizable channel specific commands
    • Custom commands
Powered by GitBook
On this page

Was this helpful?

  1. Command Validations

Syntax validations

PreviousRuntime validationsNextEvent Handling

Last updated 1 year ago

Was this helpful?

You can provide your own syntax validations that will be ran against every command. This function should throw an error if the syntax is incorrect.

Callback functions will be checked by WOKCommands automatically. There is no need to actually implement this functionality yourself.

no-callback.js
module.exports = (command) => {
  const { commandObject, commandName } = command;

  if (!commandObject.callback) {
    throw new Error(
      `Command "${commandName}" does not have a callback function.`
    );
  }
};
no-callback.ts
import { Command } from "wokcommands";

export default (command: Command) => {
  const { commandObject, commandName } = command;

  if (!commandObject.callback) {
    throw new Error(
      `Command "${commandName}" does not have a callback function.`
    );
  }
};