#4485 correctly made Telegram and Discord skip disabled handlers when platform commands are collected, but runtime changes from Dashboard → Plugins → Manage Behaviors do not currently trigger a platform command re-sync. As a result, disabling or renaming commands updates AstrBot's runtime state while already-registered native commands can remain stale on the platform. This is especially problematic near platform command-count limits because disabling commands does not promptly free those native command slots.
Modifications / 改动点
Add a default no-op Platform.refresh_registered_commands() hook so adapters that expose native commands can opt into runtime refresh without platform-specific conditionals in the dashboard service.
Refresh platform-native command registrations after a command is successfully enabled/disabled or renamed.
Discord:
replace only AstrBot-managed application commands before syncing;
serialize command refreshes with a lock;
roll back the managed local registry if synchronization fails;
pass the configured debug guild through check_guilds so stale guild commands can also be removed when the desired command set becomes empty;
preserve the existing daily application-command quota handling (30034).
Telegram:
refresh native commands for a running application after command-management changes;
delete stale platform commands when the desired command set becomes empty;
update the command hash only after the platform update succeeds so failed updates remain retryable.
Add regression coverage for command toggle/rename refresh, Discord disable/removal and rollback behavior, debug-guild empty-set synchronization, and Telegram empty-command cleanup/runtime refresh.
This is intentionally limited to the adapters that currently expose AstrBot-managed native command registration (Discord and Telegram). Other adapters inherit the no-op hook.
dosubotBot
added
size:M
This PR changes 30-99 lines, ignoring generated files.
area:platform
The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.
labels
Aug 14, 2026
casama233
changed the title
fix(command-management): refresh platform commands after command changes
fix: refresh platform commands after command changes
Aug 14, 2026
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
At least 1 approving review is required to merge this pull request.
Assignees
No one assigned
Labels
area:platform
The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.
size:M
This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
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.
Follow-up to #4485.
#4485 correctly made Telegram and Discord skip disabled handlers when platform commands are collected, but runtime changes from Dashboard → Plugins → Manage Behaviors do not currently trigger a platform command re-sync. As a result, disabling or renaming commands updates AstrBot's runtime state while already-registered native commands can remain stale on the platform. This is especially problematic near platform command-count limits because disabling commands does not promptly free those native command slots.
Modifications / 改动点
This is intentionally limited to the adapters that currently expose AstrBot-managed native command registration (Discord and Telegram). Other adapters inherit the no-op hook.
This is not a duplicate of #4485:
fix:exclude disabled commands from platform command registration #4485: disabled handlers are excluded on the next collection.
This PR: runtime command-management changes trigger that collection/sync for already-running adapters.
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Verification on the final PR commit:
The regression tests added in this PR cover:
Checklist / 检查清单