Skip to content

Fix Discord channel name getting stuck while topic keeps updating#134

Open
lex wants to merge 2 commits into
Refactorio:developfrom
lex:fix/discord-channel-name-rate-limit
Open

Fix Discord channel name getting stuck while topic keeps updating#134
lex wants to merge 2 commits into
Refactorio:developfrom
lex:fix/discord-channel-name-rate-limit

Conversation

@lex

@lex lex commented Jul 13, 2026

Copy link
Copy Markdown

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-offline while the server is running) — even though both are set by the same ModifyAsync call in ChannelUpdater.

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

  • Only send props.Name when 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.
  • After sending a name change, wait for the gateway to update the cached channel and verify the rename applied; if not, retry on a 15-minute backoff that outlasts the rate limit window instead of riding its edge.
  • Back off for a minute after cancelled requests instead of rescheduling immediately, which previously tight-looped every 10 seconds (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 PreBuild target (cmd.exe syntax) to Windows so the solution builds on macOS/Linux; CI on windows-latest is unaffected.

Tests

Updated the ChannelUpdaterTests mock 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

lex and others added 2 commits July 13, 2026 15:47
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>
@grilledham grilledham self-requested a review July 13, 2026 20:29
@grilledham

Copy link
Copy Markdown
Contributor

Interesting. I'll see if I can find time to review this later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants