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.
Git Clone Links:¶
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 thenameanddescriptionarguments)ApplicationContextis always aliased asctx.
- When you need a data from
config.ymlimportconfigfromutils.data. All the fields will be shown as attributes ofconfig. - 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 Overrideis enabled). To do this import the function named:report_error()fromutils.errors. Only the error argument is required.- The User (
discord.Memberordiscord.Userobject). Not required if no User object can be given. - 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).
- Trying to take action against Bots/Apps:
Can not {Action} Bots/Apps- Example:
Can not Ban Bots/Apps
- Example:
- 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
- Example:
- Trying to take action against yourself:
Can not {Action} Yourself- Example:
Can not Ban Yourself
- Example:
- Insufficient Coin Balance:
Insufficient Coins in User's Balance - Not in required type of Channel.
User not in a {Type of Channel}- Example:
User not in a VC
- Example:
- Trying to take action against Bots/Apps:
- The User (
- 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.
- Override Disabled:
OverrideDisabledError - 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 raiseTopiaProfileNotFoundErrorwhen no Topia Profile is found.
- It is highly unlikely you will need to raise this exception class in any cog. This is because
- 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 raiseTopiaProfileSuspendedErrorif the user is suspended.
- It is highly unlikely you will need to raise this exception class in any cog. This is because
- Override Disabled:
- 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
utilsdirectory. 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:
- GlobaLog Embed Generator
- Brave Bot Pro Acquisition Embed Generator
- Common Database Functions.
- Common Pro Functions:
- For Pro User Check use the function called
pro_user_check(). - 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.
- For User use:
pro_user_type_override_check() - For Server use:
pro_server_type_override_check()
- For User use:
- To check weather a specific part of the Pro System is enabled use the correct function.
- For Pro User Check use the function called
- Common Topia Functions.
- Overrides and their respective Functions.
- Common Discord components can also be found in the
utilsdirectory. 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 inutils.components.py.
- Common API Functions. Including:
Website Development Guide:¶
- Images should be stored in the Images folder named
assets. Only.png/.svgimages are allowed. - 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.
- We currently are not working on different languages of the website. If you wish to start please create an issue.
- 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.
- For Brave Bot do:
- When doing command scripts please ensure you put it in code-bloc and use shell/bash.
- 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.
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:¶
FORCED: If set totruea pipeline will be forced to run.WEBHOOK_URL: Used in theannounce_releasejob.UPDATE_PIPELINE: If set totrueit allows theannounce_releasejob 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.