Skip to content

EmilyxFox/janitor-discord-bot

Repository files navigation

Janitor Bot

Eventually fully featured Discord Bot
Jump to Usage

Contributing · Report Bug · Request Feature

About this project

This is a Discord bot for a private server. This project is set up to allow any member of the server to contribute features to the bot and learn about development and DevOps together.

The bot is written in Typescript to be run on the Deno runtime.

Built with

Deno TypeScript

Discord Bluesky

GitHub Docker Visual Studio Code GitHub Actions

(back to top)

Roadmap

  • Database
  • Logging
  • Image spoiler enforcement
  • Reaction roles
    • Set up database
  • Automatic bulk message deletion
  • Starboard
  • Button to remove automatic message replies
    • Permission system for it
  • Let boosters set their own colour
  • Server emoji popularity tracking

See the open issues for a full list of proposed features (and known issues).

(back to top)

Usage

Docker Compose

services:
  bot:
    # You can pin the version by using a semver tag e.g.:
    # ghcr.io/emilyxfox/janitor-discord-bot:v0.3.1
    image: ghcr.io/emilyxfox/janitor-discord-bot:latest
    restart: unless-stopped
    # This example uses an external .env file.
    # The .env file will be read when you run docker compose up
    # Environment variables can be defined directly here as well
    environment:
      DISCORD_TOKEN: ${DISCORD_TOKEN}
      # You can use the service name instead of an IP
      DB_URL: http://db:8080/
      # You can choose to deploy commands to a list of guilds or globally
      # The bot defaults to registering commands globally.
      # If you want to deploy commands to a list of guilds...
      DEPLOY_COMMANDS_TO: GUILDS
      # ...you should specify them with this list syntax.
      GUILDS: |-
        1327443723425363754
        1312443867846354378
    # Bind the /app/logs/ directory to persist logs between container restarts.
    volumes:
      - ./logs:/app/logs

  db:
    image: ghcr.io/tursodatabase/libsql-server:latest
    platform: linux/amd64
    restart: unless-stopped
    # Unless you need to access the DB from the host system
    # you don't need to bind any ports.
    # If you need this it might be a good idea to also configure auth.
    #ports:
    #  - "8080:8080"
    environment:
      - SQLD_NODE=primary
    volumes:
      - ./data/libsql:/var/lib/sqld

Environment variables

Environment Variable Description Required / Default
DISCORD_TOKEN The Discord bot token used for authentication. Required
DEPLOY_COMMANDS_TO Specifies the deployment target for commands. Accepts either GLOBAL or GUILDS (case insensitive). Optional, defaults to GLOBAL
GUILDS A newline-separated (\n) list of guild IDs where commands will be deployed (if DEPLOY_COMMANDS_TO is set to GUILDS). Optional (no default)
LOG_LEVEL Sets the log level to either DEBUG or INFO Optional, defaults to DEBUG
DB_URL The URL for connecting to the database. Must be a valid URL. Required
DB_AUTH Database authentication credentials (if needed). Optional (no default)
DEV Flag indicating development mode. Accepts "true" or "false" (case insensitive). Optional, defaults to false
REPO_URL The URL of the repository. Optional, defaults to this repository

(back to top)

Contibuting

Prerequisites

  • Deno
    • Windows:
    irm https://deno.land/install.ps1 | iex
    • Linux/Mac:
    curl -fsSL https://deno.land/install.sh | sh
  • Discord bot token
    1. Go to the Discord Developer Portal and sign in.
    2. Open the Applications tab and create a new application.
    3. Enable "Presence Intent", "Server Members Intent", and "Message Content Intent" under Privileged Gateway Intents
    4. Reset the bot token.
  • Docker for container development

Installation

  1. Fork the repo
# Github CLI
gh repo fork EmilyxFox/janitor-discord-bot
  1. Clone your fork
git clone https://github.com/{Your username}/janitor-discord-bot.git
  1. Install dependencies
deno install
  1. Make a copy of .env.example and fill the required variables
# Linux
cp ./.env.example ./.env
# Windows
Copy-Item -Path ".\.env.example" -Destination ".\.env"
  1. Run the bot
deno task dev

If it bot detects that it is not in any guilds it will output an invite link to the console.

Making upstream contributions

  1. Create a branch for your feature
git switch -c feat/my-cool-feature
  1. Commit your changes
git commit -m "I added the coolest feature!"
  1. Push your branch
git push origin feat/my-cool-feature
  1. Open a pull request

(back to top)

About

🤖 A Discord bot for our server that anyone can contribute to!

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •