Feature/capr 28 fix sync - #53
Merged
Merged
Conversation
- Refactor Sync and Ping cogs to accept bot instance via __init__ - Remove global capy_discord.instance usage in favor of self.bot - Add debug_guild_id to Settings for guild-specific commands - Fix /sync to sync both global and debug guild commands - Add hotswap command for live extension reload - Add admin permission check to /sync slash command
Contributor
Reviewer's GuideRefactors Cog initialization to inject the bot instance, introduces configuration-driven debug guild syncing for application commands, and enhances the sync tooling and documentation around command syncing and development guidelines. Sequence diagram for updated /sync slash command flowsequenceDiagram
actor AdminUser
participant DiscordClient
participant SyncCog
participant DiscordAPI
AdminUser->>DiscordClient: Invoke /sync
DiscordClient->>SyncCog: sync_slash(interaction)
SyncCog->>DiscordClient: interaction.response.defer(ephemeral=true)
SyncCog->>SyncCog: _sync_commands()
activate SyncCog
SyncCog->>DiscordAPI: bot.tree.sync() global commands
DiscordAPI-->>SyncCog: global_synced
alt debug_guild_id configured
SyncCog->>DiscordAPI: bot.tree.sync(guild=debug_guild)
DiscordAPI-->>SyncCog: guild_synced
else no debug guild
SyncCog->>SyncCog: guild_synced = None
end
deactivate SyncCog
SyncCog->>DiscordClient: interaction.followup.send(description, ephemeral=true)
opt error during sync
SyncCog->>SyncCog: raise Exception
alt interaction.response not done
SyncCog->>DiscordClient: interaction.response.send_message(error, ephemeral=true)
else response already done
SyncCog->>DiscordClient: interaction.followup.send(error, ephemeral=true)
end
end
Updated class diagram for Sync, Ping, and SettingsclassDiagram
class commands_Bot
class Settings {
+int log_level
+str prefix
+str token
+int debug_guild_id
}
class Sync {
-commands_Bot bot
-logging_Logger log
+Sync(bot commands_Bot)
+_sync_commands() tuple~list~app_commands_AppCommand~~, list~app_commands_AppCommand~~|None~
+sync(ctx commands_Context) None
+sync_slash(interaction discord_Interaction) None
}
class Ping {
-commands_Bot bot
-logging_Logger log
+Ping(bot commands_Bot)
+ping(interaction discord_Interaction) None
}
class app_commands_AppCommand
class commands_Context
class discord_Interaction
class logging_Logger
Sync --> commands_Bot : depends on
Ping --> commands_Bot : depends on
Sync --> Settings : reads debug_guild_id
Settings --> commands_Bot : configures behavior
Sync --> app_commands_AppCommand : sync results
Sync --> commands_Context : used in sync
Sync --> discord_Interaction : used in sync_slash
Ping --> discord_Interaction : used in ping
Sync --> logging_Logger : logging
Ping --> logging_Logger : logging
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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
Update Discord sync and ping cogs to use injected bot instances and support global plus debug-guild command synchronization, while documenting cog initialization and commit practices.
New Features:
Enhancements:
Documentation: