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. Commands

Inferred slash command arguments

Slash commands handle arguments differently, however WOKCommands will allow you to specify your slash command arguments in the same way as normal commands.

add.js
const { CommandType, CommandObject, CommandUsage } = require("wokcommands");

module.exports = {
  description: "Adds numbers together",

  // Only register a slash command, not a legacy command
  type: CommandType.SLASH,

  minArgs: 2,
  maxArgs: 2,
  expectedArgs: "<num1> <num2>",

  callback: ({ args }) => {
    const sum = args.reduce((acc, cur) => {
      return acc + Number(cur);
    }, 0);

    return `The sum is ${sum}`;
  },
};
add.ts
import { CommandType, CommandObject, CommandUsage } from "wokcommands";

export default {
  description: "Adds numbers together",

  // Only register a slash command, not a legacy command
  type: CommandType.SLASH,

  minArgs: 2,
  maxArgs: 2,
  expectedArgs: "<num1> <num2>",

  callback: (options: CommandUsage) => {
    const { args } = options;

    const sum = args.reduce((acc, cur) => {
      return acc + Number(cur);
    }, 0);

    return `The sum is ${sum}`;
  },
} as CommandObject

When using inferred arguments with slash commands, it's very important that you provide minArgs and expectedArgs properties.

PreviousSlash commandsNextCustom slash command arguments

Last updated 1 year ago

Was this helpful?

Behind the scenes WOKCommands will create an array of for your slash commands. As you will see in the next section you can always customize these options if need be.

options