The powerful discord bot template with Next.js Dashboard and Discord.js v14.
- Node.js Discord Bot with discord-fp
- Dashboard using Next.js App Router
- Documentation Website
- Kafka Event Streaming (Communication between server and dashboard)
- Database (Default: Vercel Posgres + Drizzle ORM)
Demo: https://money-shark.vercel.app
Clone the project:
git clone https://github.com/SonMooSans/discord-bot-template.git
Install dependencies, notice that this project uses pNPM as package manager:
pnpm i
This project is a monorepo, You can run the project in development mode:
pnpm run dev
Create Production Build:
pnpm run build
Add https://<app_url>/api/auth/callback
as a Redirect Uri in Developer Portal.
Required variables are listed in .env.example.
This project uses Upstash Kafka, you can register an account and get required credentials there.
By default, it uses Vercel Postgres as the database provider, please follow their docs to setup database.
This project uses Drizzle ORM and Vercel Postgres, you may migrate to other ORMs and database provider if you wanted.
Push database changes:
pnpm run db:push
Please make sure all environment variables are all settled before running the command.
Learn More about Drizzle ORM from their documentation.
This project is using Turborepo, you can learn more about it from their documentation.
Package | Description |
---|---|
apps/web | Web App + Documentation (Frontend) |
apps/bot | Discord Bot |
packages/docs | Documentation (Content + Utils) |
packages/ui | Components & Utils |
packages/db | Database Schema & Client |
packages/config | Configuration Files |
Learn more about these packages by reading their README.md file
It'll checks for user permissions before doing any operations.
You can enable permission checking in a Server Action or Route Handler by doing:
import { checkPermissions } from "@/utils/actions/permissions";
export async function myAction() {
"use server";
//notice that it is an async function
await checkPermissions();
}
We use Kafka for handling real-time operations via dashboard, so that no requests will be sent to the server that hosts the discord bot directly.
This brings a faster load speed and more better stability because the dashboad will still works even if the discord bot is temporarily unavailable.
The dashboard is built for serverless, you are able to deploy it to any serverless hosting platforms such as Vercel, Azure and AWS.
Notice that the Discord bot server can only be deployed to traditional Node.js Server hosting services, serverless environment is incompatible.
Because they will connect to the Discord Gateway or even need a sharding manager which isn't suitable in a serverless environment.
Typesafe is the key to maintain a large codebase. Although Javascript + JSDocs is perfect for libraries, it's still recommended to use Typescript for writing applications.
This template is fully written in Typescript, all the type errors will be reported at build time.
It is easy to deploy this application.
The fastest way to deploy Next.js applications is to use Vercel.
Any hosting platform that supports Node.js, such as AWS, Render, Railway.