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(() =>"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.

Back |


If you are looking at this you probably wonder who I am; teenage open source maintainer

shadowtime2000's DEV profile image