Fix Discord channel name getting stuck while topic keeps updating#134
Open
lex wants to merge 2 commits into
Open
Fix Discord channel name getting stuck while topic keeps updating#134lex wants to merge 2 commits into
lex wants to merge 2 commits into
Conversation
Discord has an undocumented rate limit of 2 name changes per channel per 10 minutes, separate from topic changes, and only counting fields whose value actually changes. Name changes over the limit can be dropped silently: the request succeeds and the topic is applied, but the name is left unchanged. Status transitions (offline/online, version changes) burn the name change budget in bursts, after which the 5 minute update cycle keeps re-attempting the rename inside the rolling window and the channel name gets stuck (e.g. showing offline while the topic shows players online). See discord/discord-api-docs#1900 and discord/discord-api-docs#2190. - Only send the name when it differs from the channel's current name, so routine topic updates never count towards the name change limit. - After sending a name change, verify it was applied and if not, retry on a 15 minute backoff that outlasts the rate limit window. - Back off after cancelled requests instead of retrying immediately, which tight-looped every 10 seconds while a rate limit pause was being waited out. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The PreBuild target uses cmd.exe syntax, which fails the build on macOS/Linux. CI builds on windows-latest and is unaffected; the npm build and appsettings copy are not needed to build and run the .NET tests locally on other platforms. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Interesting. I'll see if I can find time to review this later this week. |
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.
Problem
A known issue: a server's Discord channel topic (players online) keeps updating, but the channel name gets stuck (e.g. still showing
s16-offlinewhile the server is running) — even though both are set by the sameModifyAsynccall inChannelUpdater.Cause
Discord has an undocumented rate limit of 2 name changes per channel per 10 minutes, separate from topic changes, and only fields whose value actually changes count toward it (see discord/discord-api-docs#1900 and discord/discord-api-docs#2190). Name changes over the limit can be dropped silently: the request succeeds and the topic is applied, but the name is left unchanged (widely reported, e.g. this discord.js thread).
Name changes only happen on status transitions, which come in bursts: a stop/start cycle is 2 renames back-to-back, a crash loop or update cycle more, and version bumps change the name too. Once the budget is burned, the 5-minute update cycle keeps re-attempting the rename right at the rolling window's edge (2 per 10 min), so the name can stay stuck indefinitely while topics sail through — with nothing in the logs, since the requests succeed.
Fix
props.Namewhen it differs from the channel's current name (tolerating Discord's name normalization), so routine topic updates never count toward the rename limit and can't be blocked by it.requestTimeout) while a 429 pause was being waited out.Since the silent-drop behavior is undocumented, the verification is written defensively: worst case (a false negative) it retries a rename 4×/hour, well under the limit.
The second commit is separate and can be dropped if unwanted: it restricts the csproj
PreBuildtarget (cmd.exe syntax) to Windows so the solution builds on macOS/Linux; CI on windows-latest is unaffected.Tests
Updated the
ChannelUpdaterTestsmock channel to track and apply names like Discord does, and added tests for: unchanged name omitted from the PATCH, normalization-equivalent names treated as equal, and unapplied renames being retried.🤖 Generated with Claude Code