viet-aus-it / vait-discord-bot

Discord bot project for the Vietnamese Aussies in IT Discord Server
10 stars 5 forks source link
bot chatbot discord viet-aus-it

VAIT Discord Bot Project

Table of contents

Forewords

This documentation below is for contributing to the bot. For bot commands and usage, please visit our Wiki page.


Requirements

Note: From this point onwards, this document assumes you're running the database locally with Docker. If you prefer using a DBaaS instead, please fill in the .env file with the values you get from your DBaaS provider, and just skip the steps of setting up a local DB container (e.g. any steps that requires docker compose up db)

Contributions

For Contributions, please have a look these document


Onboarding

Creating your discord app and bot

Creating the config files

Using the onboarding script

On most UNIX-like systems (macOS, Linux and WSL), you should be able to run the onboarding script. This script will create a local dev environment file, install dependencies, and setup a pre-commit git hook and a local database setup via Docker.

./scripts/onboarding.sh

Please ensure that you have all the required programs/executable are installed on your machine before running the script. If somehow the script does not work for you, please let us know via the Issue tab or ping us on Discord, and you might need to follow through the manual process.

Manually

After creating your discord app and bot, create config file and fill in the values you get from the previous step

cp .env.dist .env

Note: DO NOT commit the .env file to Git.

Build and run the service locally

Run these commands at the root of the project

docker compose up -d db

pnpm install
pnpm run prisma:gen
pnpm run deploy:command
pnpm run start

Useful commands

DB migration & Client Generation

pnpm run prisma:migrate
pnpm run prisma:gen

DB GUI

pnpm run prisma:studio

Deploying your commands to a test Discord Server

// File: src/slash-commands/index.ts
import yourCommand from './your-command';

export const commandList: SlashCommand[] = [yourCommand];
// File: src/context-menu-commands/index.ts
import yourCommand from './your-command';

export const commandList: ContextMenuCommand[] = [yourCommand]
pnpm run deploy:command

Troubleshooting

Running lints and tests

pnpm run lint
pnpm run format
pnpm run test

Testing production build

cp .env.dist .env.production
docker compose -f docker-compose.production.yml build bot
docker compose -f docker-compose.production.yml up db bot