/comrade-next

The next rewrite of my personal Discord bot.

Primary LanguagePythonMIT LicenseMIT

comrade-next-logo

Discord Bot GitHub tag Python 3.11 Code Style: Black

Automated Tests CICD codecov


Comrade NEXT: The Next Great Leap for Comrade

A complete rewrite of Comrade, using interactions.py.

The goal of this bot is to become a long-term maintainable bot that I can use for the next several years. It will represent the culmination of nearly 4 years of work on my original version of Comrade which started in 2019.

Comrade NEXT represents the 7th major version of the bot, and will become integrated as Comrade 7.x after it is stable.

The current goal is to get feature parity with Comrade 5.x, Ground Dragon, and Comrade Requiem (6.x)

You can read more in the docs wiki.

Suggest improvements by creating an issue, and follow the development process!

New Practices Being Employed

  • Built-in patcher - easily update the bot from the latest version of the repository
  • Tests - unit tests for library functions, and integration tests for bot commands; testing is done in CI
  • Installing the bot as a Python package - for managing dependencies, and for easy deployment

Deployment Instructions

Requirements

  • Python 3.11+
  • Discord Bot Token
  • MongoDB cluster that you can connect to (either local or Atlas)
  • Spare Discord server for asset storage and as a communication relay

Procedure

  1. Clone the repo

  2. cd to repo root

  3. (Optional) Create a virtual environment

  4. Run pip install -e . to install the bot as a package

  5. Create a configuration file:

    • The easiest way is to make a file called .env in the repository root, with the following format:
    COMRADE_BOT_TOKEN = ...
    COMRADE_MONGODB_URI = ...
    COMRADE_TIMEZONE = ...
    COMRADE_RELAY_GUILD_ID = ...
    
    • You can also pass in values as environment variables with the same name.
    • Comrade uses python-decouple for config loading. Check their docs to see other ways to specify configuration variables.

See comrade/core/configuration.py for details on the required values.

  1. Run comrade

System Architecture

graph TD
    servers(((Discord Servers)))
    hostcomp(Host Computer with Comrade)
    mongo{{MongoDB Database}}
    relay{{Relay Server}}
    gh{{GitHub Repo, CI, CD}}
    gh -->|CD Webhook| relay
    gh -->|Pull Repo| hostcomp
    relay --> |Webhook-based Commands| hostcomp
    hostcomp --- |Asset Storage & Retrieval| relay
    hostcomp --- |Document Storage & Retrieval| mongo
    hostcomp --- |Bot Commands| servers
Loading