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}`;
  },
};

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

circle-exclamation

Last updated