Skip to content

Development Guide for IndiSpark's Repository @ Development Guide:

Welcome to IndiSpark's Development Guide!

Our two main projects are Brave Bot and our website. We use pixi as our package manager, environment manager and more. Please ensure you install Pixi beforehand.

Clone with SSH: Click Here

git@gitlab.com:indispark/brave-bot.git

Clone with HTTPS: Click Here

https://gitlab.com/indispark/brave-bot.git

Brave Bot Development Guide:

Please follow the guidelines below when modifying anything Brave Bot. Please ensure you are using the Python Version outlined in the repository's pixi.toml file.

  • Add comments explaining any confusing/complex logic.
  • When creating a slash command it must start like: @discord.slash_command() (Please ensure you fill out the name and description arguments)
    • ApplicationContext is always aliased as ctx.
  • When you need a data from config.yml import config from utils.data. All the fields will be shown as attributes of config.
  • When editing which fields exist make sure you update the Pydantic model class in utils/data.py.
  • Ephemeral messages should be in a blockquote and start with an emoji.
  • All errors be reported (this includes logging the error and sending it to Sentry if the Sentry Integration Override is enabled). To do this import the function named: report_error() from utils.errors. Only the error argument is required.
    1. The User (discord.Member or discord.User object). Not required if no User object can be given.
    2. The Error (Giving the exception is preferred, else write the error/limitation the user has ran into. Common Errors have Error Messages that you must use).
      1. Trying to take action against Bots/Apps: Can not {Action} Bots/Apps
        • Example: Can not Ban Bots/Apps
      2. Trying to take action against a user higher or equal to you: Can not {Action} Users higher than you or equal to you
        • Example: Can not Ban Users higher than you or equal to you
      3. Trying to take action against yourself: Can not {Action} Yourself
        • Example: Can not Ban Yourself
      4. Insufficient Coin Balance: Insufficient Coins in User's Balance
      5. Not in required type of Channel. User not in a {Type of Channel}
        • Example: User not in a VC
  • Use Emojis where needed.
    • Process completion messages should be ephemeral and use the tick emoji.
    • Pro Button messages should be ephemeral and use the cross emoji.
    • Error messages should be ephemeral and use cross emoji.
    • Process cancellation messages should be ephemeral and use the tick emoji.
  • Certain Brave Bot specific errors have their own Exception class.
    1. Override Disabled: OverrideDisabledError
    2. No Topia Profile Found: TopiaProfileNotFoundError
      • It is highly unlikely you will need to raise this exception class in any cog. This is because get_topia_profile() will raise TopiaProfileNotFoundError when no Topia Profile is found.
    3. Suspended Topia Profile: TopiaProfileSuspendedError
      • It is highly unlikely you will need to raise this exception class in any cog. This is because get_topia_profile() will raise TopiaProfileSuspendedError if the user is suspended.
  • When creating views ensure there is always a red "Cancel" button that edits the view to be None.
  • Please use the functions made in the utils directory. This is so the codebase is simplified and and easier to read. (Nearly all overrides have a "check" function somewhere in the utils directory. You must use it)
    • Common API Functions. Including:
      • Sentry.io Integration Functions.
      • GitLab Integration Functions.
    • Common Maths Functions.
    • Common Embed Functions:
      1. GlobaLog Embed Generator
      2. Brave Bot Pro Acquisition Embed Generator
    • Common Database Functions.
    • Common Pro Functions:
      1. For Pro User Check use the function called pro_user_check().
      2. To check if the Pro System is enabled use the function called pro_override_check()
        • To check weather a specific part of the Pro System is enabled use the correct function.
          1. For User use: pro_user_type_override_check()
          2. For Server use: pro_server_type_override_check()
    • Common Topia Functions.
    • Overrides and their respective Functions.
    • Common Discord components can also be found in the utils directory. E.g. Link Buttons. There is only one view class for Link Buttons that should be used for all cases. This view class is declared in utils.components.py.

Website Development Guide:

  1. Images should be stored in the Images folder named assets. Only .png / .svg images are allowed.
  2. When updating the layout of the website (adding, removing or renaming a page) please ensure you update the zensical.toml
    • Look at existing configuration if stuck.
  3. We currently are not working on different languages of the website. If you wish to start please create an issue.
  4. Guide Specific titles:
    • For Brave Bot do: # {title} @ Brave Bot: on the first line.
    • For the Linux Guide do: # {title} @ Linux Guide: on the first line.
    • For the Coding Guide do # {title} @ Coding Guide: on the first line.
    • For the Development & Contributor Guide do # {title} @ Development Guide: on the first line.
  5. When doing command scripts please ensure you put it in code-bloc and use shell/bash.
  6. If possible please code examples to the Community Examples folder located in the community folder.

CI/CD:

Every week on Mondays and Thursdays at 3pm UTC, checks are carried out on the repository. You can also manually trigger a pipeline by setting the CI/CD variable $FORCED to true. If you have any proposals to improve the system please create an issue.

Tip

With Pixi we have added tasks so that you can run tests locally.

Bash
1
2
3
pixi run lint
pixi run format
pixi run fix-format # fix-format will auto-fix ruff detected formatting issues.

Note

Gitleaks is not included as a local dependency, however it is enforced in GitLab CI/CD. To run Gitleaks locally, you must install it separately.

Tip

If you use VS-Code, we recommend installing the Ruff VS-Code Extension.

CI/CD Variables:

  1. FORCED: If set to true a pipeline will be forced to run.
  2. WEBHOOK_URL: Used in the announce_release job.
  3. UPDATE_PIPELINE: If set to true it allows the announce_release job to be ran during the pipeline.

Pixi:

When manually updating the pixi.toml please do pixi lock afterwards. If you do pixi upgrade [package] then you do not need to do the lock command afterwards.

Refer to Pixi Documentation for in-depth guidance, click here.