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

Setup

  1. Clone and configure:
git clone https://github.com/subkhanibnuaji/discord-bot.git
cd discord-bot
cp .env.example .env
  1. Set your bot token in .env:
DISCORD_BOT_TOKEN=your_bot_token_here
SECRET_KEY=your_random_secret_key
  1. Start:
make build && make up
  1. 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

  1. Go to Discord Developer Portal
  2. Create application → Bot → Add Bot
  3. Enable: SERVER MEMBERS INTENT + MESSAGE CONTENT INTENT
  4. Copy token to .env
  5. OAuth2 → URL Generator:
    • Scopes: bot
    • Permissions: Read Messages/View Channels, Read Message History, Manage Webhooks, Send Messages
  6. Invite bot to both source and destination servers

API Endpoints

MethodEndpointDescription
POST/api/v1/auth/registerRegister admin
POST/api/v1/auth/loginLogin
GET/api/v1/bot/statusBot status
GET/api/v1/bot/guildsList servers
GET/api/v1/bot/guilds/:id/channelsList channels
GET/api/v1/forwardingList rules
POST/api/v1/forwardingCreate rule
PATCH/api/v1/forwarding/:idUpdate rule
DELETE/api/v1/forwarding/:idDelete rule
GET/api/v1/forwarding/statsStats

API docs at /docs when running.

Tech Stack

ComponentTechnology
BackendPython 3.11, FastAPI, discord.py 2.x, SQLAlchemy (SQLite)
FrontendReact 18, TypeScript, Vite, TailwindCSS
AuthJWT + bcrypt
DeployDocker 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 .env only, 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