Giter Site home page Giter Site logo

cmxn3onwebff's Introduction

Discord Bot Template

The powerful discord bot template with Next.js Dashboard and Discord.js v14.

Features

  • 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)

Quick Start

Demo: https://money-shark.vercel.app

Installation

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

Commands

This project is a monorepo, You can run the project in development mode:

pnpm run dev

Create Production Build:

pnpm run build

Discord OAuth

Add https://<app_url>/api/auth/callback as a Redirect Uri in Developer Portal.

Environment Variables

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.

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.

Project Structure

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

Security

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();
}

Scalability

Don't depend on "Server"

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.

Serverless Ready

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

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.

Deploy

It is easy to deploy this application.

Web App

The fastest way to deploy Next.js applications is to use Vercel.

Bot Server

Any hosting platform that supports Node.js, such as AWS, Render, Railway.

cmxn3onwebff's People

Contributors

neon4real avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.