Admin Command

How To create custom Admin Commands.

The Admin Commands Can only execute by superAdmin with %prefix

Preview

addap.js
module.exports = async (message) => {
    try {
        return "addPoint"
    } catch {
        return "error execute command";
    }
}

In this example, you must use try catch for prevent the server stop, the message params carrying the message from chat.

Usage

make sure you have any correction before execute the function you have.

addap.js
module.exports = async (message) => {
    try {
        const param1 = parseInt((message.body).split(' ')[1]);
        if(isNan(param1)){
            return 'input should be a number' //correction if the second params after space isNan
        }
        ...
        return `added point ${param1} to all users success`
    } catch {
        return "error execute command";
    }
}

In this example, the command should be %addap 1000

Required

  • Try Catch Method: use the try catch everytime you make a new commands.
  • message: params from whatsapp-web-js that carrying any chat that you can create exeption with that.