hakase-discord

command module
v0.0.0-...-7c89717 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License: MPL-2.0 Imports: 15 Imported by: 0

README

hakase-discord

godoc integration codecov go report card

hakase is a collection of helpful utilities for class chatrooms, including an assignment due date reminder, study session scheduler, and more. It is currently under development. This repository holds the Discord Bot, built with Go. The backend API is in a beta state, with a Slack App planned in the future.

Backend API: https://github.com/dragonejt/hakase

Table of Contents

  • Local Development
    • Building and Running
    • Testing
    • Linting and Formatting
  • Deployment
    • Continuous Delivery

Local Development

Building and Running

Local development with hakase-discord is relatively simple. The only command you have to run is:

go run hakase-discord.go

You do have to have some environment variables in place. hakase does not directly read from a .env file, but you can configure environment variables or reference a .env file through IDE launch options. Otherwise, you can set environment variables locally.

ENV="development"
DISCORD_BOT_TOKEN="from Discord Dev Portal"
BACKEND_URL="https://hakase.dragonejt.dev" # if self-hosting, change URL to self-hosted backend
BACKEND_API_KEY="from Backend API"
NATS_URL="nats://"
STREAM_NAME="hakase_discord_local" # different from production stream name
Testing

For testing, the following command should be run, with the above environment variables in place:

go test ./...

This uses Go's built-in test runner which will discover and test all _test.go files. The integrate.yml GitHub Actions workflow will run these tests with code coverage (-coverpkg=./... -coverprofile=coverage.txt).

If you are using VS Code, the VS Code Go extension will enable automatic test discovery and running in the Testing sidebar.

Linting and Formatting

Go and the VS Code Go Extension automatically performs linting and formatting on save. The integrate.yml GitHub Actions workflow will check for linting errors and formatting mistakes with golangci-lint.

Deployment

For deployment, hakase is built into a Docker image with nixpacks, and then deployed into a container via Dokku.

On the deployed docker container, the following environment variables should be set:

ENV="production"
DISCORD_BOT_TOKEN="from Discord Dev Portal"
BACKEND_URL="https://hakase.dragonejt.dev" # if self-hosting, change URL to self-hosted backend
BACKEND_API_KEY="from Backend API"
NATS_URL="nats://"
STREAM_NAME="hakase_discord" # different from development stream name
SENTRY_DSN="from Sentry"

Dokku does support dockerized message queues, and hakase uses a dockerized NATS instance in production.

Continuous Delivery

hakase has a continuous delivery GitHub Actions workflow, deliver.yml. The steps taken are summarized:

  1. Build a Docker image with the Heroku Cloud Native Buildpacks
  2. The nixpacks GitHub Action uploads the built image to GitHub Container Registry
  3. The built docker image is deployed as a docker container via the Dokku GitHub Action
  4. A new Sentry release is created for monitoring with the Sentry Release GitHub Action.

Documentation

Overview

hakase-discord is the entry point for the Discord bot. It initializes logging, Sentry, Discord session, backend client, and event handlers. It registers application commands and starts the bot event loop.

Directories

Path Synopsis
Package clients implements backend API operations for assignments.
Package clients implements backend API operations for assignments.
Package events provides Discord event handlers for guild create and delete.
Package events provides Discord event handlers for guild create and delete.
Package interactions provides handlers for assignment actions (edit, update, delete).
Package interactions provides handlers for assignment actions (edit, update, delete).
Package settings provides environment variable configuration for the bot.
Package settings provides environment variable configuration for the bot.
Package views provides Discord message embeds and components for assignment lists.
Package views provides Discord message embeds and components for assignment lists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL