Install Type Validator
npm install --save discord-arg-validator
Look at structure
How you implement this package really depends on the structure of your bot and what framework you use. Typically, you would want to add the validation to the execute
function of your command.
const { validate, String, Number, YesNo } = require("discord-arg-validator");
module.exports = {
name: 'foo',
description: 'bar',
execute(message, args) {
validate(args, [String, Number, YesNo]).then(() => /* Command logic here */).catch(() => message.channel.send("Make sure you use the command correctly!")))
}
}
You could also use await
so you don't have to put your command login in a .then()
chain.
Top comments (0)