Skip to content

feat: add extensions system and update README #828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,8 @@ config/settings.yml
.DS_Store

docs-build/
docs/site/

# extensions
tux/extensions/*
!tux/extensions/README.md
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ It is designed to provide a variety of features to the server, including moderat
- Custom help command
- Configuration system (`config/settings.yml.example`)
- Dynamic role-based (access level) permission system
- Basic extensions system (see [extensions](tux/extensions/README.md))

## Installation and Development

Expand Down
4 changes: 4 additions & 0 deletions tux/cog_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ async def setup(cls, bot: commands.Bot) -> None:
with start_span("cog.load_regular", "Load regular cogs"):
await cog_loader.load_cogs_from_folder(folder_name="cogs")

# Finally, load cogs from the extensions folder
with start_span("cog.load_extensions", "Load extension cogs"):
await cog_loader.load_cogs_from_folder(folder_name="extensions")

total_time = time.perf_counter() - start_time

if sentry_sdk.is_initialized() and (current_span := sentry_sdk.get_current_span()):
Expand Down
13 changes: 13 additions & 0 deletions tux/extensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Extensions
This is one of the more new/basic features of Tux, however it is a very powerful one. This will let you add custom commands to Tux without having to modify the code. This is done by creating a new file in the `tux/extensions` folder. The file is just a regular Discord.py cog.

At the end of the day it is about the same as just adding a cog to the bot manually, you can also do this if you so wish (the src/ folder is docker mounted so modifications will be reflected in the container as well).

> [!TIP]
> We scan subdirectories so you can use git submodules to add extensions!

## Limitations
Unfortunately using extensions does come with some limitations:
- Everything is in the same category (Extensions)
- You cannot add your own data to the database schema (unless you want to modify the code), a solution might be added in the future.
- You cannot add extra packages (unless you modify the code), a solution might be added in the future.