KembaliArsip / superapp-automation / discord-bot
superapp-automation
discord-bot
84 file · 348.4 KB
Sistem informasi live — discord-bot-snowy-sigma.vercel.appBuka di tab baru
README
Discord Message Forwarder
Lightweight bot that forwards messages from source Discord channels to your own server in real time. No data storage — pure relay.
How It Works
Source Server #channel ──→ Bot (on_message) ──→ Your Server #channel
│
├── Uses webhook: shows original author name + avatar
├── Forwards: text, embeds, attachments, replies
└── Zero storage: nothing saved, just relayed
Features
- Real-time forwarding — Messages appear in your channel instantly
- Webhook relay — Shows original author's name and avatar (not bot name)
- Configurable rules — Pick source and destination per channel
- Attachment support — Images, files, and embeds forwarded
- Reply context — Quoted replies preserved
- Dashboard UI — Web interface to manage forwarding rules
- Lightweight — SQLite for config only, no PostgreSQL/Redis needed
- ToS compliant — Uses official Bot Token, not user token
Quick Start
Prerequisites
- Docker and Docker Compose
- Discord Bot Token (Developer Portal)
Setup
- Clone and configure:
git clone https://github.com/subkhanibnuaji/discord-bot.git
cd discord-bot
cp .env.example .env
- Set your bot token in
.env:
DISCORD_BOT_TOKEN=your_bot_token_here
SECRET_KEY=your_random_secret_key
- Start:
make build && make up
- Open http://localhost:3000, register an account, and create forwarding rules.
Without Docker
# Backend
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload
# Frontend (separate terminal)
cd frontend
npm install
npm run dev
Discord Bot Setup
- Go to Discord Developer Portal
- Create application → Bot → Add Bot
- Enable: SERVER MEMBERS INTENT + MESSAGE CONTENT INTENT
- Copy token to
.env - OAuth2 → URL Generator:
- Scopes:
bot - Permissions:
Read Messages/View Channels,Read Message History,Manage Webhooks,Send Messages
- Scopes:
- Invite bot to both source and destination servers
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/register | Register admin |
| POST | /api/v1/auth/login | Login |
| GET | /api/v1/bot/status | Bot status |
| GET | /api/v1/bot/guilds | List servers |
| GET | /api/v1/bot/guilds/:id/channels | List channels |
| GET | /api/v1/forwarding | List rules |
| POST | /api/v1/forwarding | Create rule |
| PATCH | /api/v1/forwarding/:id | Update rule |
| DELETE | /api/v1/forwarding/:id | Delete rule |
| GET | /api/v1/forwarding/stats | Stats |
API docs at /docs when running.
Tech Stack
| Component | Technology |
|---|---|
| Backend | Python 3.11, FastAPI, discord.py 2.x, SQLAlchemy (SQLite) |
| Frontend | React 18, TypeScript, Vite, TailwindCSS |
| Auth | JWT + bcrypt |
| Deploy | Docker Compose, Nginx, Vercel (frontend) |
Project Structure
discord-bot/
├── backend/
│ └── app/
│ ├── main.py # FastAPI + bot lifecycle
│ ├── config.py # Settings
│ ├── api/v1/
│ │ ├── auth.py # Login/register
│ │ ├── bot.py # Bot status, guilds, channels
│ │ └── forwarding.py # CRUD forwarding rules
│ ├── core/ # Database (SQLite), security, exceptions
│ ├── models/ # User + ForwardingRule
│ ├── schemas/ # Pydantic schemas
│ └── services/
│ └── discord_bot.py # Bot + forwarding engine
├── frontend/
│ └── src/
│ ├── pages/ # Dashboard, Rules, Servers, Settings
│ ├── components/forwarding/ # RuleList, CreateRuleForm
│ ├── hooks/useForwarding.ts # React Query hooks
│ └── services/forwarding.ts # API client
├── docker-compose.yml # 3 services: backend, frontend, nginx
└── vercel.json # Frontend deploy config
Security
- Bot Token only (never user token)
- Token in
.envonly, never committed - JWT auth for dashboard access
- No message data stored anywhere
- Webhook mentions disabled (
AllowedMentions.none())
License
MIT
File Utama
- .env.example
- .gitignore
- Makefile
- README.md
- command-builder.html
- docker-compose.yml
- index.html
- vercel.json