fix(hotswap): support AutoShardedBot and add profile test action - #54
Merged
shamikkarkhanis merged 2 commits intoJan 31, 2026
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideExtends the profile slash command with a new test action and its response, corrects the Profile cog setup docstring, and updates the hotswap tool to support both Bot and AutoShardedBot instances when validating the interaction client. Sequence diagram for hotswap callback with Bot and AutoShardedBot supportsequenceDiagram
actor User
participant Discord
participant Bot
participant HotswapSelect
User->>Discord: Trigger interaction
Discord->>Bot: Send interaction
Bot->>HotswapSelect: callback(interaction)
HotswapSelect->>HotswapSelect: read cog_name from values
HotswapSelect->>HotswapSelect: bot = interaction.client
alt client is Bot or AutoShardedBot
HotswapSelect->>HotswapSelect: proceed with hotswap logic
else client is not Bot or AutoShardedBot
HotswapSelect->>HotswapSelect: log error and return
end
Updated class diagram for Profile cog and hotswap callback typesclassDiagram
class Profile {
- bot : commands_Bot
+ Profile(bot : commands_Bot)
+ profile(interaction : discord_Interaction, action : str) void
+ handle_edit_action(interaction : discord_Interaction, action : str) void
+ handle_show_action(interaction : discord_Interaction) void
+ handle_delete_action(interaction : discord_Interaction) void
- _create_profile_embed(user : discord_User_or_Member, profile : UserProfile) discord_Embed
}
class HotswapSelect {
+ values : list_str
+ callback(interaction : discord_Interaction) void
}
class Bot {
}
class AutoShardedBot {
}
class commands_Bot {
}
class discord_Interaction {
+ client : object
+ response : InteractionResponse
}
class InteractionResponse {
+ send_message(content : str, ephemeral : bool) void
}
class UserProfile {
}
Profile --> commands_Bot : uses
Profile --> discord_Interaction : uses
Profile --> UserProfile : uses
Profile --> InteractionResponse : uses
HotswapSelect --> discord_Interaction : uses
HotswapSelect --> Bot : accepts
HotswapSelect --> AutoShardedBot : accepts
discord_Interaction --> InteractionResponse : has
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new
testprofile action appears to be a debugging hook; consider gating it behind a config flag or removing it before release so it doesn’t surface to end users in production. - When the interaction client is not a
Bot/AutoShardedBot, you only log and return; consider also sending a brief ephemeral response to the user so they’re not left with a silent failure.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `test` profile action appears to be a debugging hook; consider gating it behind a config flag or removing it before release so it doesn’t surface to end users in production.
- When the interaction client is not a `Bot`/`AutoShardedBot`, you only log and return; consider also sending a brief ephemeral response to the user so they’re not left with a silent failure.
## Individual Comments
### Comment 1
<location> `capy_discord/exts/profile/profile.py:70-71` </location>
<code_context>
await self.handle_show_action(interaction)
elif action == "delete":
await self.handle_delete_action(interaction)
+ elif action == "test":
+ await interaction.response.send_message("Profile Cog: **Test Version 2.0**", ephemeral=True)
async def handle_edit_action(self, interaction: discord.Interaction, action: str) -> None:
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider gating the `test` action behind a permission or env check so it doesn't leak to regular users.
Since this is an internal verification endpoint, exposing it as a normal `profile` action makes it discoverable in help/autocomplete and leaks internal version info. Consider restricting it (e.g., owner-only, specific role, env flag) or moving it to a dedicated dev/debug cog.
```suggestion
elif action == "test":
# Restrict the internal test action to the bot owner so it is not usable by regular users.
is_owner = await self.bot.is_owner(interaction.user)
if not is_owner:
await interaction.response.send_message(
"This action is restricted to the bot owner.",
ephemeral=True,
)
return
await interaction.response.send_message(
"Profile Cog: **Test Version 2.0**",
ephemeral=True,
)
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
shamikkarkhanis
deleted the
feature/capr-27-port-hotswapreload-command
branch
January 31, 2026 06:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Extend hotswap tooling compatibility and add a test action to the profile command.
New Features:
Bug Fixes:
Enhancements: