A WhatsApp bot built with Node.js, TypeScript, and Firebase.
-
Clone the repository:
git clone https://github.com/Cyberkingcr7/bnh-md cd bnh-md -
Install dependencies:
yarn install # or npm install -
Firebase Setup:
This bot uses Firebase for its database. You need to provide a service account key.
- Go to the Firebase Console.
- Select your project (or create a new one).
- Go to Project settings > Service accounts.
- Click Generate new private key.
- A JSON file will be downloaded.
- Rename this file to
sui.json. - Place
sui.jsonin the root directory of the project (the same folder aspackage.json).
Important: Do not share your
sui.jsonfile. It contains sensitive credentials.
To start the bot, run:
tsc
npm startIf you want to host this bot , i'd suggest Railway or Fly.io.
You can add new commands by creating files in the src/cmd directory. You can organize them into subfolders (e.g., src/cmd/General, src/cmd/MyCategory).
Create a new file, for example src/cmd/General/hello.ts:
import { Ctx } from "../../lib/ctx";
module.exports = {
name: "hello", // The command name (e.g., !hello)
category: "General", // Category for the help menu
code: async (ctx: Ctx) => {
// ctx contains information about the message and sender
// Reply to the user
await ctx.reply("Hello there! 👋");
},
};- name: The trigger for the command (without the prefix).
- category: The category under which the command will appear in the help menu.
- code: An async function that executes the command logic. It receives a
ctx(Context) object.
The ctx object provides helper methods and properties to interact with the message and the user.
ctx.reply(text): Reply to the message with text.ctx.sender.jid: The JID (ID) of the sender.ctx.args: Array of arguments passed to the command.