rename path: fix env-var mismatch, gut canRename gate, add primary-bot fallback on 401/403/429
- secondary rename-bot token was set as RENAME_TOKEN in .env but utils/renamer.js reads RENAMER_BOT; silently no-op'd every rename (host .env renamed separately)
- services/tickets.js canRename gutted to an always-ok shim; Mongo 2/10min per-channel gate is redundant since renames flow through RENAMER_BOT's own bucket. Ticket.renameCount / renameWindowStart remain as orphan fields (no migration)
- handlers/buttons.js + commands.js: drop the four "Channel renamed too quickly" else-branches and the rename-countdown label suffix; replace .catch(() => {}) with .catch(err => logError('rename', err)...)
- services/channelQueue.js: executeRename falls back to channel.setName(currentName) when renamer throws err.fallback === true (401/403/429); classifies non-fallback errors as renameQueue:token/permission (401/403) or renameQueue:secondary-bot ratelimited (429)
- utils/renamer.js: on 401/403 throw err.fallback=true immediately; on 429 respect retry_after up to 2000ms then throw err.fallback=true
- docs: align CLAUDE.md, docs/api/DISCORD_API_VALIDATION.md, docs/architecture/CRITICAL_FILES_AND_HOW_IT_WORKS.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -245,12 +245,10 @@ Our code creates channels and renames them without explicit rate limit handling.
|
||||
|
||||
**Discord Rate Limits:**
|
||||
- Channel creation: 50/day per guild
|
||||
- Channel rename: 2 per 10 minutes per channel
|
||||
- Channel rename: 2 per 10 minutes per channel **per bot token**
|
||||
|
||||
**Our Protection:**
|
||||
- ✅ We have rename rate limiting via `canRename()` function (2 renames per 10 minutes per channel)
|
||||
- ✅ Tracks `rename_count` and `rename_window_start` on the ticket
|
||||
- ✅ When limit is reached, skips rename and posts in the ticket: *Channel renamed too quickly. Try again \<t:unlock:R\>.*
|
||||
- ✅ Renames route through `utils/renamer.js` (RENAMER_BOT secondary token). On 401/403/429 from the secondary, `services/channelQueue.js` falls back to the primary bot via `channel.setName`. `canRename()` is retained as an always-ok shim for back-compat.
|
||||
|
||||
**Recommendation:** Current implementation is GOOD. No changes needed.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user