1.0.6 • Published 10 months ago
baileys-boilerplate v1.0.6
Baileys Boilerplate
Boilerplate for Baileys Whatsapp bot
Usage
npx baileys-boilerplateType Bot
This boilerplate has two types of options for the bot. namely Case Type and Plugin Type
Plugin
All bot commands are stored in the plugin/ sub directory according to the type of command e.g. downloads for the downloader command. You can also add your own command categories. Example commands for this type:
Module (ESM)
export default {
  name: "Ping", // Command name
  triggers: ["ping", "p"], //Trigger (Can be more than one)
  code: async (ctx) => {
    //the content of the command
    ctx.reply("pong"); // Command to reply to a message
  },
};Common (CJS)
module.exports = {
  name: "Ping", // Command name
  triggers: ["ping"], //Trigger (Can be more than one)
  code: async (ctx) => {
    //the content of the command
    ctx.reply("pong"); // Command to reply to a message
  },
};Case
This type uses a switch case to handle incoming commands. to add commands, simply add a new case. For example:
switch (cmd.toLowerCase()) {
  case ".ping":
    ctx.reply("Pong");
    break;
  default:
    break;
}You only need to add the case:
case "hi":
	ctx.reply("Hi, how can I help you?");
	break;For commands that want to have multiple triggers you can do this:
case "hello", "hi":
	ctx.reply("Hi, how can I help you?");
	break;Running Bot
There are a couple of options to run this Bot, namely using QRCode and Pairing Code. Here is how to run it:
Connect with QR Code
npm startConnect with Pairing Code
npm run use-pairing-codeLicense
This package is licensed under the MIT License.