Skip to content
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

feat: dev command for managing extensions #34

Merged
merged 9 commits into from
Jul 3, 2024

Conversation

n0Oo0Oo0b
Copy link
Contributor

This allows for hot-reloading cogs in extensions (i.e. changes can be reloaded without having to restart the whole bot).

Usage:

  • <prefix>ext list: shows a list of loaded extensions
  • <prefix>ext load <ext_name>: loads a new extension (not loaded yet)
  • <prefix>ext unload <ext_name>: unloads a loaded extension
  • <prefix>ext reload <ext_name>: reloads an already loaded extension

Extensions are assumed to be in cogs/. <ext_name> can be just the name of the extension (e.g. dev) or the full path (e.g. cogs.dev).

Note that changes in app commands may have to be synced separately (sync *) after (re-)loading an extension.

n0Oo0Oo0b added 3 commits May 20, 2024 20:42
We probably want a better check for this, but I'm just adding this now in case it reaches production
Copy link
Collaborator

@ilikecubesnstuff ilikecubesnstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing these! I have left a few comments, but I also wanted to ask: are these commands ever to be used in production? Or is this just for development convenience?

cogs/dev.py Outdated Show resolved Hide resolved
cogs/dev.py Outdated Show resolved Hide resolved
cogs/dev.py Outdated Show resolved Hide resolved
n0Oo0Oo0b added 2 commits May 20, 2024 22:30
Required permission is `manage_guild` as per ib-ai#34 (comment) (highest perm that SysAdmins have)
@n0Oo0Oo0b
Copy link
Contributor Author

are these commands ever to be used in production? Or is this just for development convenience?

I'm adding this mainly for development convenience but I could see this being used in production too (e.g. if a vulnerability is found in a specific cog then the rest of the bot can run as normal while it gets patched)

@n0Oo0Oo0b n0Oo0Oo0b force-pushed the extensions-command branch from 7380f23 to cf09663 Compare May 25, 2024 13:40
Copy link
Collaborator

@NathanealV NathanealV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Should only be a couple quick changes - please see my PR comments.

cogs/dev.py Outdated Show resolved Hide resolved
cogs/dev.py Outdated Show resolved Hide resolved
cogs/dev.py Outdated Show resolved Hide resolved
Changes made:
- Strip extension names before processing
- Use existing `utils.commands.available_subcommands` instead of `ctx.send_help` for consistency (this may be changed back later in ib-ai#36)
- Typehints for `ctx`
- Docstring formatting consistency
- Logging of load/unload/reloading of extensions
NathanealV
NathanealV previously approved these changes Jun 19, 2024
Copy link
Collaborator

@NathanealV NathanealV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@ilikecubesnstuff ilikecubesnstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@NathanealV NathanealV merged commit 2a4c0f8 into ib-ai:rewrite Jul 3, 2024
1 check passed
@n0Oo0Oo0b n0Oo0Oo0b deleted the extensions-command branch July 4, 2024 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants