Skip to content

uwblueprint/bobatalks

Repository files navigation

๐ŸŒธ BobaTalks Flowers Bot

A UW Blueprint x BobaTalks project that automates the Flowers tradition โ€” letting students celebrate wins through a Discord bot and displaying approved posts on the BobaTalks website.


๐Ÿงญ Overview

This project includes:

  • Discord Bot โ€“ Collects "Flowers" submissions and handles moderation.
  • Web App (Next.js) โ€“ Displays approved Flowers on the BobaTalks site.
  • Database (Supabase) โ€“ Stores submissions and approvals securely.
  • CI/CD โ€“ Enforces code quality and consistency through GitHub Actions.

โš™๏ธ Tech Stack

Layer Technology
Bot Node.js + TypeScript + discord.js
Web Next.js 15 + Tailwind CSS
Database Supabase (PostgreSQL)
CI/CD GitHub Actions
Code Quality ESLint, Prettier, Husky, TypeScript strict mode

โœ… Local Setup Checklist

Check Command Expected Result
Node.js installed node -v โ‰ฅ 22.x
npm installed npm -v shows a version number
Dependencies installed npm ci completes without errors
Linting passes npm run lint no errors or warnings
Formatting passes npm run format -- --check . no changed files
TypeScript clean npx tsc --noEmit no type errors
Precommit works git commit -m "test: husky check" runs precommit checks automatically

๐Ÿง‘โ€๐Ÿ’ป Getting Started

1๏ธโƒฃ Clone the repository

git clone https://github.com/uwblueprint/bobatalks-flowers.git
cd bobatalks-flowers

2๏ธโƒฃ Install dependencies

npm ci

3๏ธโƒฃ Set up environment variables

cp .env.example .env

Fill in the placeholder values

4๏ธโƒฃ Run code quality checks locally

npm run lint
npm run format -- --check .
npx tsc --noEmit

If these three pass, your setup is perfect โœ….


๐Ÿฅช Verifying Pre-commit Hooks

We use Husky + lint-staged to enforce formatting before commits.

Test it:

git add .
git commit -m "test: check husky hook"

Expected: Prettier and ESLint run automatically before committing.

If hooks donโ€™t run:

npx husky install

๐Ÿงฑ Continuous Integration (CI)

Every push and PR triggers GitHub Actions to run:

  • โœ… Linting (npm run lint)
  • โœ… Formatting check (npm run format -- --check .)
  • โœ… TypeScript check (npx tsc --noEmit)

PRs canโ€™t be merged unless these checks pass.

To simulate CI locally:

npm ci
npm run lint
npm run format -- --check .
npx tsc --noEmit

๐Ÿ”ง Common Fix Commands

Issue Fix
ESLint errors npm run lint --fix
Prettier issues npm run format
Husky hook not running npx husky install
TypeScript โ€œNo inputs foundโ€ Create a src/ folder or place .ts files at root

๐Ÿ‘ฉโ€๐Ÿ’ป Contributing Guidelines

  1. Create a new branch:

    git checkout -b feature/your-feature-name
  2. Commit using Conventional Commits:

    • feat: โ†’ new feature
    • fix: โ†’ bug fix
    • chore: โ†’ tooling / configs
  3. Push and open a PR โ€” CI must pass before merging.


๐Ÿงฎ Scripts Summary

Command Description
npm run lint Run ESLint
npm run format Format with Prettier
npm run format -- --check . Check Prettier formatting (read-only)
npx tsc --noEmit Type-check only
npx husky install Reinstall Git hooks
npm run dev Run Discord bot in dev mode
npm run build Build TypeScript to JavaScript
npm run register Register Discord slash commands
npm start Run built Discord bot

๐Ÿค– Discord Bot

The Discord bot code is located in src/bot/. See src/bot/README.md for detailed bot documentation.


๐Ÿš€ Deployment to EC2

The bot auto-deploys daily at 4 AM Toronto time (9 AM UTC) via GitHub Actions.

Prerequisites

1. Add GitHub Secrets (Settings โ†’ Secrets and variables โ†’ Actions):

  • EC2_HOST โ†’ Your EC2 IP address
  • EC2_SSH_KEY โ†’ Your entire .pem file contents

2. Setup EC2 (one-time):

ssh -i your-key.pem ubuntu@your-ec2-ip

# Install Node.js 20 & PM2
sudo apt-get update
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g pm2

# Setup project
mkdir -p ~/bobatalks/logs
cd ~/bobatalks

# Create .env file
nano .env
# Add: DISCORD_TOKEN=... and DISCORD_CLIENT_ID=...

# Enable PM2 on boot
pm2 startup systemd -u ubuntu --hp /home/ubuntu
# Run the sudo command that PM2 prints

3. Deploy:

  • Auto: Pushes to main deploy at 4 AM daily
  • Manual: GitHub โ†’ Actions โ†’ "Deploy BobaTalks" โ†’ Run workflow

4. Register commands (after first deploy):

ssh -i your-key.pem ubuntu@your-ec2-ip
cd ~/bobatalks
node dist/bot/registerCommands.js
pm2 logs bobatalks

Useful PM2 Commands

pm2 status              # Check status
pm2 logs bobatalks      # View logs
pm2 restart bobatalks   # Restart
pm2 reload bobatalks    # Zero-downtime reload

๐Ÿ’ก Run this one-liner to confirm everything works:

npm run lint && npm run format -- --check . && npx tsc --noEmit

โœ… If you see no output โ€” congrats, your setup is perfect!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •