shegraf
v1.0.0
Published
Shegraf: multi-platform bot helper for WhatsApp (Baileys), Telegram and Discord.
Maintainers
Readme
shegraf
Multi-platform bot for WhatsApp (Baileys), Telegram, and Discord with colorful buttons and WhatsApp pairing code support.
This package is designed so anyone can quickly run a personal or small‑scale bot without touching the internal code.
Features
- WhatsApp bot using @whiskeysockets/baileys
- Device-link pairing code support
- Simple command handler (e.g.
!menu) - Reply with emoji-colored buttons (WhatsApp does not support true colored button backgrounds)
- Telegram bot using Telegraf
/startand/menucommands- Inline buttons: Red, Green, Blue
- Discord bot using discord.js v14
- Text command (default:
!menu) - Colored buttons (Danger/Success/Primary)
- Colored embed response
- Text command (default:
- Single CLI entry point to start all enabled platforms.
Installation
Install globally (recommended for running the bot from anywhere):
npm install -g shegrafOr use it once without global install:
npx shegrafCLI Usage
Once installed globally, run:
shegrafBehind the scenes this runs the CLI script at src/index.js which:
- Starts the WhatsApp bot (if
WA_PHONE_NUMBERis set) - Starts the Telegram bot (if
TELEGRAM_BOT_TOKENis set) - Starts the Discord bot (if
DISCORD_BOT_TOKENis set)
If any of these environment variables is missing, that platform is simply skipped with an informational log message. The process does not crash.
Environment Variables
Set the following variables to enable each platform.
Common
COMMAND_PREFIX(optional)- Default:
! - Used for text commands on WhatsApp and Discord (e.g.
!menu)
- Default:
WhatsApp (Baileys)
WA_PHONE_NUMBER(required to enable WhatsApp)- Format: international, numbers only.
- Example (Indonesia):
62812xxxxxxxx
- Example (Indonesia):
- Format: international, numbers only.
When WA_PHONE_NUMBER is provided and the device is not yet registered, the bot will:
- Print a QR code to the terminal
- Print a pairing code for device link
WhatsApp data is stored in a local folder (multi-file auth) under:
auth/whatsappTelegram
TELEGRAM_BOT_TOKEN(required to enable Telegram)- Example:
123456789:AA...from BotFather
- Example:
Discord
DISCORD_BOT_TOKEN(required to enable Discord)- Obtain from Discord Developer Portal
- Make sure the MESSAGE CONTENT INTENT is enabled for the bot
Platform Details
1. WhatsApp (Baileys)
Powered by @whiskeysockets/baileys.
Main behavior:
- Connects using Baileys with multi-file auth
- If not registered:
Requests pairing code for
WA_PHONE_NUMBERLogs something like:
[WA] Pairing code for 62812xxxxxxxx: ABCD-EFGH
Pairing Steps
Set
WA_PHONE_NUMBER(numbers only, e.g.62812xxxxxxxx)Run:
shegrafIn the terminal you will see:
- QR code
- Pairing code (e.g.
ABCD-EFGH)
On your phone:
- Open WhatsApp
- Go to Linked devices / Perangkat tertaut
- Tap Link a device
- Either scan the QR code or choose the option to enter a device code and type the pairing code from the terminal.
After pairing, the bot is connected to your WhatsApp account.
WhatsApp Commands
- Default prefix:
!
Send to the bot:
!menuThe bot responds with a menu containing three buttons:
- 🔴 Merah
- 🟢 Hijau
- 🔵 Biru
Note: WhatsApp does not support true colored button backgrounds like Discord, so the color effect comes from the emojis and labels.
2. Telegram
Powered by telegraf.
Once TELEGRAM_BOT_TOKEN is set and the CLI is running, the bot:
- Responds to
/start - Responds to
/menu
Both commands send a message with inline buttons:
- 🔴 Merah
- 🟢 Hijau
- 🔵 Biru
On button press, the bot replies with which color you selected.
Setup Steps
Talk to @BotFather on Telegram and create a bot
Copy the bot token and set it as:
export TELEGRAM_BOT_TOKEN="your-telegram-bot-token"or on Windows (PowerShell):
setx TELEGRAM_BOT_TOKEN "your-telegram-bot-token"Run:
shegrafOpen your bot chat and send
/startor/menu.
3. Discord
Powered by discord.js v14.
Once DISCORD_BOT_TOKEN is set and the CLI is running, the bot:
- Listens to messages in guild channels
- Responds to text command (default):
!menu
The bot replies with a message containing three buttons:
- Merah (Danger style, red)
- Hijau (Success style, green)
- Biru (Primary style, blurple/blue)
When you click a button, it responds with an embed:
- Title:
Pilihan Warna - Description:
Kamu pilih <color> - Embed color matching the button (red/green/blue)
Setup Steps
Create an application & bot at Discord Developer Portal
Enable the MESSAGE CONTENT INTENT in the bot settings
Generate an invite URL with
botscope and necessary permissions (e.g. Send Messages, Read Message History)Invite the bot to your server
Set the environment variable:
export DISCORD_BOT_TOKEN="your-discord-bot-token"or on Windows (PowerShell):
setx DISCORD_BOT_TOKEN "your-discord-bot-token"Run:
shegrafIn a text channel, type:
!menu
Programmatic Usage (Library)
You can also use this package as a library inside your own Node.js project, not only as a CLI.
Install in your project
npm install shegrafImport and use
CommonJS example:
const {
startWhatsApp,
startTelegram,
startDiscord,
startAll,
createShegraf
} = require("shegraf");
// Option 1: Start everything (WhatsApp, Telegram, Discord) reading from env
startAll();
// Option 2: Start everything with explicit options (no .env required)
startAll({
whatsapp: {
phoneNumber: "62812xxxxxxxx",
pairingLog: ({ phoneNumber, code }) => {
console.log("PAIRING", phoneNumber, code);
}
},
telegram: {
token: "your-telegram-bot-token"
},
discord: {
token: "your-discord-bot-token",
commandPrefix: "!"
}
});
// Option 3: Start only specific platforms using options
startWhatsApp({ phoneNumber: "62812xxxxxxxx" });
startTelegram({ token: "your-telegram-bot-token" });
startDiscord({ token: "your-discord-bot-token", commandPrefix: "!" });
// Option 4: Use high-level Shegraf wrapper
const bot = createShegraf({
whatsapp: { phoneNumber: "62812xxxxxxxx" },
telegram: { token: "your-telegram-bot-token" },
discord: { token: "your-discord-bot-token", commandPrefix: "!" }
});
bot.start();All environment variables described in the previous sections (WA_PHONE_NUMBER, TELEGRAM_BOT_TOKEN, DISCORD_BOT_TOKEN, COMMAND_PREFIX) are still supported, but any explicit options you pass to the functions take precedence.
You can combine this with your own configuration file (for example config.js) and other application logic.
Local Development
If you clone the repository instead of using the published package:
git clone https://github.com/sherifcld/sherif-multi-bot.git
cd sherif-multi-bot
npm installYou can try the library example:
cd example
cp config.example.js config.js # or copy manually on WindowsEdit config.js and fill in your own WhatsApp number and tokens, then run:
node index.jsThis starts all enabled platforms based on your config file.
Security Notes
- Never share your
DISCORD_BOT_TOKEN,TELEGRAM_BOT_TOKEN, or WhatsApp auth files - If you suspect your tokens have leaked, revoke and regenerate them immediately
- For production use, consider running the bot on a separate machine or server
License
MIT License. See the repository or npm page for full details.
