Module: Args - Paultje52/BananenBase GitHub Wiki

The args module lets you add easy argument checking to your bot.

For example, you have a ban command. It has two arguments that are required: member and reason. The args module lets you add easy checks to make sure that the required arguments are there.

Configuration

The args module doesn't have any startup configurations

Command options

Name: Args
Value: Needs to be an object with these options.

  • Usage: String, use %prefix% for the prefix, The usage of the command
  • Examples: String array, use %prefix% for the prefix, The examples of how to use the command
  • Checks: Object array with these options.
    • Name: String, the name of the argument
    • Test: A function, returns true if everything is good and false if the argument isn't good.

Example

In the command constructor

super(BananenBase, {
  name: "ban",
  description: "Ban someone!"
}, {
  name: "args",
  value: {
    usage: "%prefix%ban <@member> <reason>",
    examples: ["%prefix%ban @Paul Lol", "%prefix%ban @Someone Advertising in PM"],
    checks: [{
      name: "@member",
      test: (message, argument) => message.mentions.members.first() || message.guild.members.cache.get(argument)
    }, {
      name: "reason",
      test: (message, argument) => typeof argument === "string"
    }]
  }
});
// Added checks for "@member" and "reason" for the ban command.
⚠️ **GitHub.com Fallback** ⚠️