DEV Community

Cover image for I Built a Self-Hosted JavaScript Discord Bot with SQLite for Small Communities (Moderation, Tickets, Giveaways & Weekly Recaps)
Yousef-Anwar777
Yousef-Anwar777

Posted on Edited on

I Built a Self-Hosted JavaScript Discord Bot with SQLite for Small Communities (Moderation, Tickets, Giveaways & Weekly Recaps)

NovaBot

Small Discord servers usually face a frustrating choice: install five separate bots that each demand their own dashboard, paywalls, and permission tweaks, or wire together a messy custom script that breaks every single time Discord updates its API.

I built NovaBot to give small communities a single, self-hosted JavaScript Discord bot backed by a local SQLite database. No external database server, no bloated SaaS subscriptions, and no complex microservices—just a clean, modular Node.js project you can run locally or in Docker and shape entirely around your server's actual habits.

Why a Local SQLite Bot Fits Small Communities

When you run a bot for a tight-knit group, friend server, or niche community, reliability and simplicity matter far more than horizontal scaling. A standalone database service adds extra moving parts, unnecessary memory overhead, and another thing you have to worry about backing up.

Storing state in a local SQLite file keeps everything self-contained:

  • Zero database friction: Your server settings, warning history, XP progress, giveaways, reminders, and community nominations live in one local file that persists safely across restarts.
  • Straightforward backups: Backing up your bot's state is as simple as copying a single database file or mounting a persistent volume in Docker.
  • Fast local iteration: You can test slash commands, button interactions, and scheduled tasks directly on your own machine before rolling updates out to your live community.

What NovaBot Does Out of the Box

Rather than splitting server essentials across multiple third-party bots, NovaBot groups everyday management tools into one cohesive codebase:

  • Moderation & Warnings: Handles bans, kicks, timeouts, message clearing, slowmode, channel locks, and warning histories—including an automatic timeout once a member hits your custom warning threshold.
  • Lightweight Automod: Filters out unwanted Discord invite links and excessive user mentions before they clutter chat.
  • Leveling & Role Rewards: Tracks chat activity for XP, displays ranks and leaderboards, and automatically grants roles when members reach specific milestones.
  • Support Tickets: Spins up private ticket channels via a button click and generates a clean transcript of recent messages sent straight to a log channel when closed.
  • Giveaways & Polls: Runs button-based giveaways with multi-winner selection, automated rerolls, and quick reaction polls so members can vote without leaving Discord.
  • Reminders & Starboard: Lets users schedule personal reminders and automatically surfaces popular messages in a dedicated starboard channel once they cross your reaction threshold.
  • Nova Replay (Weekly Community Recap): Empowers members to nominate memorable public messages, vote on favorites, and publish a weekly digest of top-voted moments with links back to the original posts—without archiving private channels or scraping every chat message indiscriminately.
  • Server Utilities: Includes welcome messages, autorole assignment, audit logs, and handy everyday utility commands like /ping, /avatar, and /serverinfo.

How the Project Is Structured

One of my main goals with NovaBot was keeping the JavaScript architecture clean, readable, and easy to extend without over-engineering:

  • Entry & Command Registration: Dedicated scripts handle bootstrapping the Discord client and syncing slash command definitions with Discord's API.
  • Database Layer: A central module manages schema setup and helper queries for server settings and community data.
  • Feature-Grouped Handlers: Slash commands, Discord gateway events, and button interactions are organized logically so you can easily trace how a user action flows from a button click to a database update.
  • Shared Utilities & Checks: Reusable helpers handle tasks like leveling math, reminder delivery, and logging, backed by automated tests and command sanity checks.

Adding a new slash command is designed to be low-friction: create a command module under the commands directory with its definition and execution handler, run the command deploy script, and Discord picks up the updated interface instantly.

Getting Started Locally or with Docker

If you want to spin up your own instance, the setup workflow is intentionally straightforward:

  1. Create the Discord App & Bot: Register an application in the Discord Developer Portal, grab your Application ID and bot token, enable the required gateway intents (Server Members Intent and Message Content Intent), and invite the bot to a test server with only the permissions it needs.
  2. Install & Configure: Install dependencies using Node.js 20, copy .env.example to .env, and configure your DISCORD_TOKEN, CLIENT_ID, and optional GUILD_ID (which is super handy for near-instant command updates in a test server).
  3. Deploy Commands & Run: Register your slash commands, start the application, and test basic commands like /ping or /help.
  4. Configure Your Server: Set up your log, welcome, starboard, and support channels via slash commands, configure auto-mod and level roles, and verify your active settings.

If you prefer containerized deployments, building the Docker image and attaching a persistent volume to the data directory ensures your SQLite database remains secure across container restarts.

Designing for Privacy and Clarity

A small detail I cared deeply about—especially with Nova Replay—is respecting user boundaries. Instead of logging every single message sent in the server by default, Nova Replay only records explicit nominations and votes from channels visible to the general public, automatically skipping deleted or restricted messages. That keeps the feature fun and community-driven without turning the bot into an invasive chat archive.


What features do you actually keep turned on in a small Discord server, and which ones end up feeling like noise after a week?

Top comments (1)

Collapse
 
pierre_mege_8167a88b5cb01 profile image
Daniel Henry Pierre •

Love this. One bot, one SQLite file, and a recap feature that respects people's privacy. That's exactly what small servers need. The care you put into Nova Replay really shows. In my experience moderation and reminders always stay on, and leveling fades fast. Thanks for building and sharing it! 💙