fix(discord): retry slash sync after failed fingerprint

This commit is contained in:
Gille 2026-07-29 12:06:42 -06:00 committed by Teknium
parent b84389c625
commit 6d292fd5eb
2 changed files with 85 additions and 9 deletions

View file

@ -1773,18 +1773,24 @@ class DiscordAdapter(BasePlatformAdapter):
if retry_after_until > now:
remaining = max(1, int(retry_after_until - now))
return f"Discord asked us to wait before syncing slash commands; retry in {remaining}s"
if entry.get("fingerprint") == fingerprint and entry.get("last_success_at"):
last_success_at = float(entry.get("last_success_at") or 0)
last_attempt_at = float(entry.get("last_attempt_at") or 0)
if (
entry.get("fingerprint") == fingerprint
and last_success_at
and last_success_at >= last_attempt_at
):
return "same slash-command fingerprint already synced"
return None
def _record_command_sync_attempt(self, app_id: Any, fingerprint: str) -> None:
state = self._read_command_sync_state()
state[self._command_sync_state_key(app_id)] = {
**(
state.get(self._command_sync_state_key(app_id))
if isinstance(state.get(self._command_sync_state_key(app_id)), dict)
else {}
),
key = self._command_sync_state_key(app_id)
entry = state.get(key) if isinstance(state.get(key), dict) else {}
entry.pop("last_success_at", None)
entry.pop("summary", None)
state[key] = {
**entry,
"fingerprint": fingerprint,
"last_attempt_at": time.time(),
}