CodeX
This commit is contained in:
21
bot/LICENSE
Normal file
21
bot/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 CodeX Devs
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
215
bot/README.md
Normal file
215
bot/README.md
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
<div align="center">
|
||||||
|
|
||||||
|
```
|
||||||
|
███████╗██╗ ██╗██████╗ ██████╗ ██╗ ██╗
|
||||||
|
╚══███╔╝╚██╗ ██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝
|
||||||
|
███╔╝ ╚████╔╝ ██████╔╝██║ ██║ ╚███╔╝
|
||||||
|
███╔╝ ╚██╔╝ ██╔══██╗██║ ██║ ██╔██╗
|
||||||
|
███████╗ ██║ ██║ ██║╚██████╔╝██╔╝ ██╗
|
||||||
|
╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
|
||||||
|
**ZyroX Bot — Python Discord Bot + FastAPI Backend**
|
||||||
|
|
||||||
|
[](https://python.org)
|
||||||
|
[](https://fastapi.tiangolo.com)
|
||||||
|
[](https://discordpy.readthedocs.io)
|
||||||
|
[](LICENSE)
|
||||||
|
[](https://discord.gg/codexdev)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Overview
|
||||||
|
|
||||||
|
This folder contains the ZyroX Discord bot built on `discord.py v2` with a `FastAPI` backend that powers the web dashboard. It handles all server moderation, music, leveling, and utility features.
|
||||||
|
|
||||||
|
```
|
||||||
|
bot/
|
||||||
|
├── api/ FastAPI backend (routes, schemas, db manager)
|
||||||
|
├── cogs/
|
||||||
|
│ ├── antinuke/ Antinuke protection events
|
||||||
|
│ ├── automod/ Automod enforcement events
|
||||||
|
│ ├── commands/ All slash & prefix commands
|
||||||
|
│ └── events/ General Discord event listeners
|
||||||
|
├── utils/ Shared utilities (emoji, tools, sync)
|
||||||
|
├── assets/ Fonts, backgrounds, GIFs
|
||||||
|
└── CodeX.py Entry point
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Features
|
||||||
|
|
||||||
|
**🛡️ Antinuke**
|
||||||
|
- Protection against mass ban, kick, channel/role flood, webhook abuse, bot adds, prune, and more
|
||||||
|
- Whitelist / unwhitelist system
|
||||||
|
- Emergency lockdown mode
|
||||||
|
|
||||||
|
**🤖 Automod**
|
||||||
|
- Anti-spam, anti-caps, anti-links, anti-invites
|
||||||
|
- Mass mention and emoji spam protection
|
||||||
|
- Fully configurable per server
|
||||||
|
|
||||||
|
**🎵 Music**
|
||||||
|
- Lavalink v4 powered playback
|
||||||
|
- YouTube, SoundCloud, JioSaavn support
|
||||||
|
- Queue, loop, shuffle, autoplay, seek controls
|
||||||
|
|
||||||
|
**⚙️ Moderation & Management**
|
||||||
|
- Ban, kick, mute, warn, lock, and more
|
||||||
|
- Logging, reaction roles, vanity roles
|
||||||
|
- Tickets, giveaways, verification, join-to-create VC
|
||||||
|
|
||||||
|
**🎉 Engagement**
|
||||||
|
- Leveling & XP system
|
||||||
|
- Birthday tracker, AFK, autorole
|
||||||
|
- Counting, blackjack, slots, autoresponder, sticky messages
|
||||||
|
|
||||||
|
**🔧 Developer**
|
||||||
|
- Jishaku eval support
|
||||||
|
- Application emoji auto-sync
|
||||||
|
- Slash + prefix commands
|
||||||
|
- FastAPI backend with API key auth
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Setup
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
| Requirement | Version |
|
||||||
|
|---|---|
|
||||||
|
| Python | 3.10 or higher |
|
||||||
|
| A Lavalink node | v4 |
|
||||||
|
| Discord bot token | — |
|
||||||
|
|
||||||
|
### 1 — Install dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m venv .venv
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
.venv\Scripts\activate
|
||||||
|
|
||||||
|
# Linux / macOS
|
||||||
|
source .venv/bin/activate
|
||||||
|
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2 — Configure environment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `.env`:
|
||||||
|
|
||||||
|
```env
|
||||||
|
# ── Core ──────────────────────────────────────
|
||||||
|
TOKEN = your_discord_bot_token
|
||||||
|
brand_name = 'ZyroX'
|
||||||
|
|
||||||
|
# ── Lavalink ──────────────────────────────────
|
||||||
|
LAVALINK_HOST = "lava-v4.ajieblogs.eu.org"
|
||||||
|
LAVALINK_PASSWORD = "your_password"
|
||||||
|
LAVALINK_SECURE = "true" # true = HTTPS (no port needed)
|
||||||
|
LAVALINK_PORT = "" # only needed when LAVALINK_SECURE=false
|
||||||
|
|
||||||
|
# ── Emoji Sync ────────────────────────────────
|
||||||
|
EMOJI_SYNC = "true" # auto-uploads & patches emoji.py on startup
|
||||||
|
|
||||||
|
# ── API / Dashboard Backend ───────────────────
|
||||||
|
API_ENABLED = "true" # false = skip starting the FastAPI server
|
||||||
|
API_PORT = "8000"
|
||||||
|
DASHBOARD_API_KEY = "change_this_to_a_strong_secret"
|
||||||
|
|
||||||
|
# ── Webhooks ──────────────────────────────────
|
||||||
|
WEBHOOK_URL = "https://discord.com/api/webhooks/..."
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3 — Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python CodeX.py
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Environment Reference
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `TOKEN` | — | Discord bot token |
|
||||||
|
| `LAVALINK_HOST` | — | Lavalink server hostname (no protocol) |
|
||||||
|
| `LAVALINK_PASSWORD` | — | Lavalink password |
|
||||||
|
| `LAVALINK_SECURE` | `true` | `true` = HTTPS, `false` = HTTP |
|
||||||
|
| `LAVALINK_PORT` | _(empty)_ | Port — only needed when `LAVALINK_SECURE=false` |
|
||||||
|
| `EMOJI_SYNC` | `true` | Run application emoji sync on startup |
|
||||||
|
| `API_ENABLED` | `true` | Start the FastAPI dashboard backend |
|
||||||
|
| `API_PORT` | `8000` | Port the backend listens on |
|
||||||
|
| `DASHBOARD_API_KEY` | — | Shared secret between bot API and dashboard |
|
||||||
|
| `WEBHOOK_URL` | — | Discord webhook for command logs |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Emoji Sync
|
||||||
|
|
||||||
|
When `EMOJI_SYNC=true`, the bot automatically syncs application emojis on every startup:
|
||||||
|
|
||||||
|
```
|
||||||
|
★ Starting Application Emoji Sync — 140 unique emojis found in emoji.py
|
||||||
|
◈ Found 140 templates | Application hosts 98 emojis
|
||||||
|
↑ Uploading: ztick (not in application emojis)
|
||||||
|
✔ Uploaded: ztick [saved as ID: 1234567890]
|
||||||
|
✔ emoji.py patched in-place to reflect current API state.
|
||||||
|
★ Restarting bot to load updated emoji IDs...
|
||||||
|
```
|
||||||
|
|
||||||
|
- New emojis → uploaded to your application, ID written to `emoji.py`
|
||||||
|
- Stale IDs → `emoji.py` is patched automatically
|
||||||
|
- No changes → sync completes instantly, no restart
|
||||||
|
- After any patch → bot restarts itself so fresh IDs are live immediately
|
||||||
|
|
||||||
|
Set `EMOJI_SYNC=false` to disable entirely.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Deployment
|
||||||
|
|
||||||
|
Upload the entire `bot/` folder to your host (Render, Railway, Fly.io, VPS) and set the start command to:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python CodeX.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Add all environment variables from `.env.example`. Make sure port `API_PORT` (`8000` by default) is publicly reachable if you're using the dashboard.
|
||||||
|
|
||||||
|
> Recommended free/cheap hosts: [NexioHost](https://nexiohost.in) · Render · Railway
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Troubleshooting
|
||||||
|
|
||||||
|
| Problem | Fix |
|
||||||
|
|---|---|
|
||||||
|
| Bot fails to start | Check `TOKEN` is set correctly and the bot has the right gateway intents |
|
||||||
|
| Music not working | Verify `LAVALINK_HOST`, `LAVALINK_SECURE`, and `LAVALINK_PORT` are correct |
|
||||||
|
| Dashboard can't load data | Confirm `API_ENABLED=true`, bot is running, and `NEXT_PUBLIC_API_URL` in the dashboard is correct |
|
||||||
|
| Emojis showing as plain text | Run with `EMOJI_SYNC=true` once to upload and patch IDs |
|
||||||
|
| Port conflict on API | Change `API_PORT` in `.env` and update `NEXT_PUBLIC_API_URL` in the dashboard |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
Developed with ❤️ by **CodeX Devs**
|
||||||
|
|
||||||
|
[](https://discord.gg/codexdev)
|
||||||
|
[](https://nexiohost.in)
|
||||||
|
|
||||||
|
*ZyroX — Built for protection. Designed for style.*
|
||||||
|
|
||||||
|
</div>
|
||||||
21
dashboard/LICENSE
Normal file
21
dashboard/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 CodeX Devs
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,2 +1,179 @@
|
|||||||
# Dashboard
|
<div align="center">
|
||||||
Project for Discord Bot Management.
|
|
||||||
|
```
|
||||||
|
███████╗██╗ ██╗██████╗ ██████╗ ██╗ ██╗
|
||||||
|
╚══███╔╝╚██╗ ██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝
|
||||||
|
███╔╝ ╚████╔╝ ██████╔╝██║ ██║ ╚███╔╝
|
||||||
|
███╔╝ ╚██╔╝ ██╔══██╗██║ ██║ ██╔██╗
|
||||||
|
███████╗ ██║ ██║ ██║╚██████╔╝██╔╝ ██╗
|
||||||
|
╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
|
||||||
|
**ZyroX Dashboard — Next.js Web Interface**
|
||||||
|
|
||||||
|
[](https://nextjs.org)
|
||||||
|
[](https://typescriptlang.org)
|
||||||
|
[](https://tailwindcss.com)
|
||||||
|
[](LICENSE)
|
||||||
|
[](https://discord.gg/codexdev)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Overview
|
||||||
|
|
||||||
|
This folder contains the ZyroX web dashboard built with `Next.js 14` (App Router), `TypeScript`, and `Tailwind CSS`. It connects to the bot's FastAPI backend to let server admins manage all bot settings through a modern UI.
|
||||||
|
|
||||||
|
```
|
||||||
|
dashboard/
|
||||||
|
├── app/ App Router pages & API routes
|
||||||
|
│ ├── api/ Next.js API routes (auth callbacks, etc.)
|
||||||
|
│ ├── dashboard/ Per-server settings pages
|
||||||
|
│ ├── docs/ Documentation page
|
||||||
|
│ ├── privacy/ Privacy policy page
|
||||||
|
│ └── terms/ Terms of service page
|
||||||
|
├── components/
|
||||||
|
│ ├── dashboard/ Dashboard-specific UI components
|
||||||
|
│ └── ui/ Reusable base components
|
||||||
|
├── hooks/ Custom React hooks
|
||||||
|
├── lib/ API helpers, auth config, utilities
|
||||||
|
└── types/ TypeScript type definitions
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Features
|
||||||
|
|
||||||
|
- **Discord OAuth2 login** — secure sign-in with your Discord account
|
||||||
|
- **Per-server management** — configure antinuke, automod, leveling, and more per guild
|
||||||
|
- **Live bot stats** — view real-time data from the bot
|
||||||
|
- **Fully branded** — customisable name, logo, and colours via environment variables
|
||||||
|
- **Vercel-ready** — deploys in minutes with zero config changes
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Setup
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
| Requirement | Version |
|
||||||
|
|---|---|
|
||||||
|
| Node.js | 18 or higher |
|
||||||
|
| ZyroX bot running | with `API_ENABLED=true` |
|
||||||
|
| Discord OAuth app | — |
|
||||||
|
|
||||||
|
### 1 — Install dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2 — Configure environment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env.local
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `.env.local`:
|
||||||
|
|
||||||
|
```env
|
||||||
|
NEXT_PUBLIC_API_URL = http://localhost:8000/api/v1
|
||||||
|
NEXT_PUBLIC_DASHBOARD_API_KEY = your_shared_api_key # must match bot's DASHBOARD_API_KEY
|
||||||
|
|
||||||
|
NEXTAUTH_URL = http://localhost:3000
|
||||||
|
NEXTAUTH_SECRET = a_long_random_string
|
||||||
|
|
||||||
|
DISCORD_CLIENT_ID = your_discord_oauth_client_id
|
||||||
|
DISCORD_CLIENT_SECRET = your_discord_oauth_client_secret
|
||||||
|
|
||||||
|
NEXT_PUBLIC_ADMIN_IDS = your_discord_user_id
|
||||||
|
NEXT_PUBLIC_BRAND_NAME = "ZyroX"
|
||||||
|
NEXT_PUBLIC_BRAND_NAME_WORD = "ZX"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3 — Run locally
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:3000](http://localhost:3000)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Environment Reference
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
|---|---|
|
||||||
|
| `NEXT_PUBLIC_API_URL` | Full URL to the bot's FastAPI backend |
|
||||||
|
| `NEXT_PUBLIC_DASHBOARD_API_KEY` | Must match `DASHBOARD_API_KEY` in the bot `.env` |
|
||||||
|
| `NEXTAUTH_URL` | Your dashboard's public URL |
|
||||||
|
| `NEXTAUTH_SECRET` | Random secret for NextAuth session signing |
|
||||||
|
| `DISCORD_CLIENT_ID` | Discord OAuth2 client ID |
|
||||||
|
| `DISCORD_CLIENT_SECRET` | Discord OAuth2 client secret |
|
||||||
|
| `NEXT_PUBLIC_ADMIN_IDS` | Comma-separated Discord user IDs with admin access |
|
||||||
|
| `NEXT_PUBLIC_BRAND_NAME` | Bot name shown in the dashboard UI |
|
||||||
|
| `NEXT_PUBLIC_BRAND_NAME_WORD` | Short abbreviation shown in the dashboard |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Deployment (Vercel)
|
||||||
|
|
||||||
|
Vercel is the recommended host — the project is pre-configured for it.
|
||||||
|
|
||||||
|
**Step 1 — Upload to Vercel**
|
||||||
|
|
||||||
|
Go to [vercel.com](https://vercel.com) → **Add New Project** → connect your GitHub repo and set the root directory to `dashboard/`.
|
||||||
|
|
||||||
|
Vercel auto-detects Next.js — no build settings needed.
|
||||||
|
|
||||||
|
**Step 2 — Add environment variables**
|
||||||
|
|
||||||
|
In your Vercel project → **Settings → Environment Variables**, add all keys from `.env.example`.
|
||||||
|
|
||||||
|
| Variable | Example Value |
|
||||||
|
|---|---|
|
||||||
|
| `NEXT_PUBLIC_API_URL` | `https://your-bot.render.com/api/v1` |
|
||||||
|
| `NEXT_PUBLIC_DASHBOARD_API_KEY` | same value as bot's `DASHBOARD_API_KEY` |
|
||||||
|
| `NEXTAUTH_URL` | `https://your-app.vercel.app` |
|
||||||
|
| `NEXTAUTH_SECRET` | [generate one here](https://generate-secret.vercel.app/32) |
|
||||||
|
| `DISCORD_CLIENT_ID` | from [Discord Developer Portal](https://discord.com/developers/applications) |
|
||||||
|
| `DISCORD_CLIENT_SECRET` | from Discord Developer Portal |
|
||||||
|
| `NEXT_PUBLIC_ADMIN_IDS` | your Discord user ID |
|
||||||
|
|
||||||
|
**Step 3 — Add redirect URI in Discord**
|
||||||
|
|
||||||
|
Go to your app in the [Discord Developer Portal](https://discord.com/developers/applications) → **OAuth2 → Redirects** → add:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://your-app.vercel.app/api/auth/callback/discord
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 4 — Deploy**
|
||||||
|
|
||||||
|
Hit **Deploy**. Vercel builds and publishes automatically. ✓
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✦ Troubleshooting
|
||||||
|
|
||||||
|
| Problem | Fix |
|
||||||
|
|---|---|
|
||||||
|
| Auth error on login | Check Discord OAuth client ID/secret and redirect URI in Developer Portal |
|
||||||
|
| Dashboard can't load data | Confirm the bot is running with `API_ENABLED=true` and `NEXT_PUBLIC_API_URL` is correct |
|
||||||
|
| `NEXTAUTH_SECRET` error | Make sure `NEXTAUTH_SECRET` is set and non-empty |
|
||||||
|
| API key mismatch | `NEXT_PUBLIC_DASHBOARD_API_KEY` must exactly match `DASHBOARD_API_KEY` in the bot |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
Developed with ❤️ by **CodeX Devs**
|
||||||
|
|
||||||
|
[](https://discord.gg/codexdev)
|
||||||
|
[](https://nexiohost.in)
|
||||||
|
|
||||||
|
*ZyroX — Built for protection. Designed for style.*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user