A powerful, self-hosted Discord bot platform built with SvelteKit 2 (Svelte 5) and deployed on Cloudflare Pages. Create custom slash commands, build event-driven automations, and monitor all Discord activity through a beautiful admin dashboard.
- Custom Slash Commands โ Create your own commands with parameters, choices, and custom responses
- Event-Driven Automations โ Trigger actions automatically when Discord events occur
- Full Gateway Support โ Real-time event capture via Discord.js gateway connection
- Interactions Endpoint โ HTTP-based slash command handling via Cloudflare Workers
- Server Selection โ Manage all servers where you're an admin
- Event Logs โ View detailed logs of all Discord activity (members, messages, voice, moderation, etc.)
- Automation Builder โ Visual interface to create event โ action automations
- Command Builder โ Design custom slash commands with the automation action system
- Dark/Light Theme โ Beautiful UI with theme toggle support
- Discord OAuth2 โ Secure login with Discord credentials
- Admin Access Control โ Only server admins can manage their servers
- Request Signature Verification โ All Discord interactions are cryptographically verified
- Cloudflare Pages โ Deployed on Cloudflare's global edge network
- D1 Database โ SQLite-based serverless database for logs and configurations
- Zero Cold Starts โ Fast response times worldwide
๐ Server Admin (Dark Mode)
View event logs, statistics, and quick access to automations and commands.
โก Automations
Create event-driven automations that trigger on Discord events like member joins, message creates, voice state changes, and more.
๐ ๏ธ Automation Editor
Visual interface for configuring triggers, conditions, and actions for your automations.
๐ฎ Custom Commands
Build custom slash commands with parameters and tie them to automation actions.
โ๏ธ Command Editor
Design slash commands with options, parameters, and custom responses through an intuitive editor.
| Layer | Technology |
|---|---|
| Framework | SvelteKit 2 (Svelte 5) |
| Runtime | Cloudflare Pages/Workers |
| Database | Cloudflare D1 (SQLite) |
| Bot Library | Discord.js 14 |
| Styling | Custom CSS with CSS Variables |
| Auth | Discord OAuth2 |
- Node.js 18+
- A Discord Application (create one here)
- A Cloudflare account (sign up here)
- (Optional) cloudflared for local tunneling
-
Clone the repository
git clone https://github.com/starspacegroup/spacebot.git cd spacebot -
Install dependencies
npm install
-
Configure environment variables
Copy
.env.exampleto.envand fill in your Discord credentials:cp .env.example .env
Required variables:
Variable Description DISCORD_PUBLIC_KEYFound in your app's "General Information" DISCORD_CLIENT_IDYour application's Client ID DISCORD_CLIENT_SECRETFound under OAuth2 settings DISCORD_BOT_TOKENFound under "Bot" settings ADMIN_USER_IDSComma-separated Discord user IDs with global admin access LOG_LEVELLogging verbosity: error,warn,info,debug -
Set up the database (local development)
npm run db:migrate:local
-
Run the development server
npm run dev
The app will be available at
http://localhost:5173 -
Start the Gateway bot (in a separate terminal)
npm run dev:gateway
This captures Discord events and processes automations.
- Go to Discord Developer Portal
- Select your application โ Bot
- Enable Privileged Gateway Intents:
- โ Presence Intent
- โ Server Members Intent
- โ Message Content Intent
- Go to OAuth2 โ URL Generator
- Scopes:
bot,applications.commands - Permissions: Administrator (or customize as needed)
- Scopes:
- Use the generated URL to invite the bot to your server
For production, configure Discord to send interactions to your Cloudflare Pages URL:
- Deploy to Cloudflare Pages (see Deployment)
- Go to Discord Developer Portal โ Your Application โ General Information
- Set Interactions Endpoint URL to:
https://your-domain.pages.dev/api/discord/interactions
| Script | Description |
|---|---|
npm run dev |
Start SvelteKit dev server |
npm run dev:wrangler |
Run with Wrangler (Cloudflare local environment) |
npm run dev:gateway |
Start Discord gateway bot |
npm run dev:tunnel |
Start cloudflared tunnel for local development |
npm run build |
Build for production |
npm run db:migrate |
Run database migrations (production) |
npm run db:migrate:local |
Run database migrations (local) |
npm run register-commands |
Register slash commands with Discord |
SpaceBot's automation engine lets you create powerful event-driven workflows:
- Member Events โ Join, leave, ban, unban, kick, timeout
- Message Events โ Create, edit, delete, bulk delete
- Voice Events โ Join, leave, mute, deafen, stream, video
- Role Events โ Create, delete, update, member role add/remove
- Channel Events โ Create, delete, update
- Reaction Events โ Add, remove
- Interaction Events โ Slash commands, button clicks, modals
- And many more...
- ๐จ Send Message โ Send a message to a channel
- ๐๏ธ Delete Messages โ Delete messages from a user
- ๐ท๏ธ Add/Remove Role โ Modify member roles
- ๐ข Kick Member โ Kick a member from the server
- ๐จ Ban Member โ Ban a member
- โฐ Timeout Member โ Timeout a member
- ๐ข Send DM โ Send a direct message to a user
Use dynamic variables in your messages:
Welcome {user.mention} to {guild.name}!
Available: {user.id}, {user.name}, {user.mention}, {channel.name},
{guild.name}, {option.<name>}, and more.
Create custom slash commands through the web dashboard:
- Navigate to Admin โ Your Server โ Commands
- Click New Command
- Configure:
- Command name and description
- Parameters (text, numbers, users, channels, roles, etc.)
- Response message or embed
- Optional: Tie to an automation action
- Click Register with Discord to sync
SpaceBot captures and logs all Discord events:
| Category | Events |
|---|---|
| ๐ค Member | Join, leave, update, nickname changes |
| ๐ฌ Message | Create, edit, delete, bulk delete |
| ๐ค Voice | Join, leave, mute, deafen, stream, video |
| ๐ Channel | Create, delete, update |
| ๐ท๏ธ Role | Create, delete, update, member assignments |
| ๐จ Moderation | Ban, unban, kick, timeout |
| โก Interaction | Commands, buttons, modals, select menus |
| ๐ Events | Scheduled event create, update, delete |
-
Push to GitHub
git push origin main
-
Connect to Cloudflare Pages
- Go to Cloudflare Dashboard
- Workers & Pages โ Create application โ Pages โ Connect to Git
- Select your repository
- Configure:
- Build command:
npm run build - Build output:
.svelte-kit/cloudflare
- Build command:
-
Add Environment Variables In Cloudflare Pages Settings โ Environment Variables, add all required variables.
-
Create D1 Database
wrangler d1 create spacebot-logs
Update
wrangler.tomlwith the database ID. -
Run Migrations
npm run db:migrate
-
Deploy Future pushes to
mainwill auto-deploy.
See DEPLOYMENT.md for detailed instructions.
spacebot/
โโโ src/
โ โโโ lib/
โ โ โโโ automation/ # Automation engine
โ โ โโโ components/ # Svelte components
โ โ โโโ db/ # Database functions
โ โ โ โโโ automations.js
โ โ โ โโโ commands.js
โ โ โ โโโ logger.js
โ โ โโโ discord/ # Discord integration
โ โ โโโ cache.js
โ โ โโโ commands.js
โ โ โโโ gateway.js # Gateway bot service
โ โ โโโ guilds.js
โ โโโ routes/
โ โ โโโ admin/ # Admin dashboard pages
โ โ โ โโโ [serverId]/ # Per-server management
โ โ โ โ โโโ automations/
โ โ โ โ โโโ commands/
โ โ โ โ โโโ logs/
โ โ โโโ api/ # API endpoints
โ โ โ โโโ automations/
โ โ โ โโโ commands/
โ โ โ โโโ discord/
โ โ โ โโโ logs/
โ โ โโโ login/
โ โโโ app.html
โโโ migrations/ # D1 database migrations
โโโ scripts/ # Utility scripts
โโโ static/ # Static assets
โโโ docs/
โโโ screenshots/ # Documentation images
- โ Discord request signature verification
- โ HTTP-only secure cookies
- โ Admin permission checks
- โ Environment variable secrets
- โ HTTPS via Cloudflare
See ROADMAP.md for planned features and enhancements.
MIT






