Commit 63a0d17
committed
Only deploy commands when they have actually changed
The container's CMD is `validate && deploy && start`, so every restart bulk
overwrote every global command — needless API traffic, and a rate-limit risk
during a crash loop. Global command propagation is also not instant, so
redeploying identical payloads on every boot bought nothing.
deploy-commands.ts now fingerprints what it is about to send (the global
payload, the owner-guild payload, the client id and the guild id) and stores
the hash in the existing Keyv/SQLite store. If the fingerprint matches the
last successful deploy it skips entirely. `--force` / `-f` overrides, and
`--clear` drops the stored fingerprint so the next deploy runs.
setCommands() now reports whether the calls succeeded, and the fingerprint is
recorded only if they did. It previously caught and logged errors while
returning normally, so without that the first failed deploy would have been
remembered as successful and never retried.
Verified end to end against a bogus token:
1. failed deploy -> nothing recorded, "the next run will retry"
2. run again -> retries, does not skip
3. fingerprint seeded as a success -> skips, zero API calls
4. --force -> deploys anyway
5. BOT_GUILD_ID changed -> fingerprint differs, deploys
6. a command description edited -> fingerprint differs, deploys
7. edit reverted -> skips again
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015hDX4g1EjTN7424A5wnptE1 parent b049b11 commit 63a0d17
2 files changed
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
11 | 26 | | |
12 | 27 | | |
13 | 28 | | |
| |||
17 | 32 | | |
18 | 33 | | |
19 | 34 | | |
20 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
21 | 39 | | |
22 | 40 | | |
23 | 41 | | |
| |||
26 | 44 | | |
27 | 45 | | |
28 | 46 | | |
| 47 | + | |
29 | 48 | | |
30 | 49 | | |
31 | 50 | | |
| |||
37 | 56 | | |
38 | 57 | | |
39 | 58 | | |
| 59 | + | |
40 | 60 | | |
41 | 61 | | |
42 | 62 | | |
43 | 63 | | |
44 | 64 | | |
45 | 65 | | |
46 | 66 | | |
| 67 | + | |
47 | 68 | | |
48 | 69 | | |
49 | 70 | | |
| |||
66 | 87 | | |
67 | 88 | | |
68 | 89 | | |
69 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
70 | 104 | | |
71 | 105 | | |
72 | 106 | | |
73 | 107 | | |
| 108 | + | |
74 | 109 | | |
0 commit comments