haikz-discord-bot
v1.0.0
Published
Discord bot untuk commerce, ticket, server cloning, dan automation. Stack: Node.js + discord.js + better-sqlite3 + Express webhook.
Readme
HaikzBot — Discord Commerce Platform
Discord bot untuk commerce, ticket, server cloning, dan automation. Stack: Node.js + discord.js + better-sqlite3 + Express webhook.
Features
✅ Setup Wizard — /setup auto-create kategori store / ticket / welcome / logs
✅ Server Clone — /clone snapshot di server lama, /clone apply di server baru. Copy roles, channels, categories, permissions. Tidak menyalin member/pesan/history.
✅ Store + QRIS — /product add, /stock add, /store panel. Auto-delivery via DM saat bayar.
✅ Ticket System — panel + auto-create channel, claim, transcript HTML dengan auto-redact (email/phone/token/QRIS).
✅ Welcome + Logs — auto-greet member baru, account-age check, audit log.
✅ Emoji — /emoji add upload via URL/attachment.
✅ Automation — order expiry, daily report, low-stock alert ke owner.
✅ Web webhook — Tripay QRIS, mock provider buat dev.
Setup
cd /root/main/discord-bot
cp .env.example .env
# Edit .env — minimal isi: DISCORD_TOKEN, CLIENT_ID, OWNER_ID, DEV_GUILD_ID
npm install
npm run deploy # register slash commands
npm start.env wajib
DISCORD_TOKEN= # dari Discord Developer Portal → Bot
CLIENT_ID= # Application ID
OWNER_ID= # Discord user ID kamu
DEV_GUILD_ID= # Server testing (instant register).env optional
PAYMENT_PROVIDER=mock # tripay | mock
TRIPAY_API_KEY=
TRIPAY_PRIVATE_KEY=
TRIPAY_MERCHANT_CODE=
WEB_BASE_URL=https://your-domain.com # for callback URLsCara dapet token Discord
- Buka https://discord.com/developers/applications
- New Application → Bot → Reset Token → copy ke
DISCORD_TOKEN - OAuth2 → URL Generator → centang
bot+applications.commands - Bot Permissions: Administrator (atau permission spesifik: Manage Channels, Manage Roles, Manage Webhooks, Manage Emojis, Send Messages, Embed Links, Attach Files, Read Message History, Manage Messages, Create Public Threads)
- Invite link → buka di browser → pilih server kamu
- Application ID di General Information → copy ke
CLIENT_ID
Discord Intents (PENTING)
Di Bot page, enable:
- ✅ Server Members Intent (buat welcome / member event)
- ✅ Message Content Intent (buat ticket auto-respond AI)
- ✅ Presence Intent (optional)
Test flow
/setup→ klik Full Setup — auto-create kategori store/ticket/welcome/logs/product add name:"VPN Premium" price:50000— buat produk/stock add product_id:1 content:"user1:pass1 | user2:pass2"— isi stok/store panel channel:#products— kirim panel beli- Klik produk dari menu → invoice generated → klik tombol Bayar
- Mock provider auto-success → DM otomatis dengan stok
Server clone
- Di server lama:
/clone snapshot— bot bikin snapshot (return ID misalnya5) - Invite bot ke server baru
- Di server baru:
/clone apply snapshot_id:5→ pilihFull clone - Bot create roles + categories + channels + permissions
Architecture
src/
├── index.js # entry point
├── core/
│ ├── db.js # better-sqlite3 schema + helpers
│ └── loader.js # auto-load commands & events
├── commands/ # slash commands
│ ├── setup.js
│ ├── clone.js
│ ├── ticket.js
│ ├── store.js
│ ├── product.js
│ ├── stock.js
│ ├── emoji.js
│ ├── config.js
│ └── help.js
├── events/
│ ├── ready.js
│ ├── interactionCreate.js
│ └── guildMemberAdd.js
├── modules/
│ ├── server-clone/ # snapshot + apply
│ ├── setup-wizard/ # full setup auto-create
│ ├── ticket/ # buttons + transcript
│ ├── store/ # checkout flow
│ ├── payment/ # provider abstraction + delivery
│ └── automation/ # cron scheduler
└── web/
└── server.js # Express webhook receiverDatabase
SQLite di data/bot.db. Schema lengkap di src/core/db.js. Tables:
guilds— config per serverproducts+stock— katalogorders— transaksitickets— sistem ticketclone_snapshots— server clone snapshotsaudit_log— semua action
Production checklist
- [ ] Pasang Tripay credentials di
.env - [ ] Set
WEB_BASE_URLke domain public (untuk callback) - [ ] Reverse proxy (nginx) ke port
WEB_PORT(default 4002) dengan TLS - [ ] Whitelist Tripay IP di firewall
- [ ] PM2 / systemd untuk auto-restart
- [ ] Backup
data/bot.dbdaily - [ ] Monitor
/api/statsendpoint
