Skip to content

Fix: don't show "Join discord" for discord users#3111

Closed
internet-addict-xyz wants to merge 1 commit intoopenfrontio:mainfrom
internet-addict-xyz:fix/discord-button
Closed

Fix: don't show "Join discord" for discord users#3111
internet-addict-xyz wants to merge 1 commit intoopenfrontio:mainfrom
internet-addict-xyz:fix/discord-button

Conversation

@internet-addict-xyz
Copy link

Resolves #3093

Description:

If the user is logged in with Discord, then don't promote it at the end of a match.

Please complete the following:

  • I have added screenshots for all UI updates

    This doesn't change anything that I can show in screenshots.

  • I process any text displayed to the user through translateText() and I've added it to the en.json file

    I didn't change any display text.

  • I have added relevant tests to the test directory

    No tests required.

  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

    Yes I did.

Please put your Discord username so you can be contacted if a bug or regression is found:

internet_addict_

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

Walkthrough

The WinModal component now checks if a user is already a Discord member. When the random branch would display the Discord promo, it shows a pattern button instead if the user has a Discord account linked. The state is populated from user data during pattern content loading.

Changes

Cohort / File(s) Summary
Discord Membership Gating
src/client/graphics/layers/WinModal.ts
Added hasDiscord state field to track Discord account presence. Modified render logic to conditionally show pattern button instead of Discord promo when user is already a Discord member. Flag is populated in loadPatternContent by checking user data.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🎵 No need to join what's yours to keep,
The Discord invite takes a leap,
Check the badge, the pattern shows,
One less banner—wisdom flows! 💜

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: preventing Discord promotion from showing to users already logged in via Discord.
Description check ✅ Passed The description clearly relates to the changeset by explaining the purpose of hiding Discord promotions for Discord-authenticated users.
Linked Issues check ✅ Passed The PR implements the core requirement from #3093: preventing the Discord join prompt from showing when a user is logged in via Discord.
Out of Scope Changes check ✅ Passed All changes are directly related to #3093: the hasDiscord field and conditional rendering logic support the stated objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VariableVince
Copy link
Contributor

Thanks! Though, them having a logged-in Discord account doesn't mean they are member of the Openfront discord server, or does it?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/client/graphics/layers/WinModal.ts`:
- Around line 166-169: The current loadPatternContent() sets this.hasDiscord
using me.user.discord !== undefined which only detects a linked Discord account,
not server membership; update loadPatternContent (and related logic that uses
this.hasDiscord) to verify actual Openfront server membership instead of just a
linked account — either by reading a dedicated membership flag returned by
getUserMe() (e.g., me.user.isOpenfrontMember or similar) or by adding a new API
call that checks membership (e.g., checkDiscordServerMembership(userId) or a
backend endpoint) and set this.hasDiscord only when that membership check
succeeds; ensure you adjust any downstream UI usage to rely on the membership
check rather than me.user.discord.
🧹 Nitpick comments (1)
src/client/graphics/layers/WinModal.ts (1)

169-169: Add optional chaining for safer property access.

If me.user is ever undefined (API edge case or future change), this line throws. Using optional chaining is a small defensive improvement.

Suggested fix
-    this.hasDiscord = me !== false && me.user.discord !== undefined;
+    this.hasDiscord = me !== false && me.user?.discord !== undefined;

Comment on lines 166 to +169
async loadPatternContent() {
const me = await getUserMe();
const patterns = await fetchCosmetics();
this.hasDiscord = me !== false && me.user.discord !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, check if the file exists and read context around the specific lines
echo "=== Reading WinModal.ts context (lines 160-175) ==="
wc -l src/client/graphics/layers/WinModal.ts
sed -n '160,175p' src/client/graphics/layers/WinModal.ts

echo -e "\n=== Searching for Discord server/membership logic ==="
rg -n "discord" --type=ts -i | grep -i "member\|guild\|server\|openfront" | head -20

echo -e "\n=== Searching for broader patterns around hasDiscord usage ==="
rg -n "hasDiscord" --type=ts -C3

echo -e "\n=== Looking for guild or server membership checks ==="
rg -n "guild\|membership\|member.*server" --type=ts -i | head -20

Repository: openfrontio/OpenFrontIO

Length of output: 2346


🏁 Script executed:

#!/bin/bash
# Check issue `#3093` references or comments in code
echo "=== Searching for issue `#3093` or related promo/membership logic ==="
rg -n "3093\|Openfront.*community\|community.*server" --type=ts -i

echo -e "\n=== Checking how getUserMe() is used and what it returns ==="
rg -n "getUserMe|user\.discord" --type=ts -B2 -A2 | head -40

Repository: openfrontio/OpenFrontIO

Length of output: 2804


The code checks only if Discord is linked, not if the user is a server member.

The current implementation at line 169 sets hasDiscord based on me.user.discord !== undefined, which indicates a linked Discord account. However, issue #3093 requires hiding the promo if the user "is already a member of the Openfront community server." These are not the same—linking Discord does not guarantee server membership.

No explicit server membership verification exists in the codebase. Either:

  1. The app's flow implicitly guarantees that linking Discord means the user is already in the server, or
  2. An explicit membership check is needed (e.g., via Discord API or stored membership flag)

Clarify which behavior is intended and update the implementation if needed.

🤖 Prompt for AI Agents
In `@src/client/graphics/layers/WinModal.ts` around lines 166 - 169, The current
loadPatternContent() sets this.hasDiscord using me.user.discord !== undefined
which only detects a linked Discord account, not server membership; update
loadPatternContent (and related logic that uses this.hasDiscord) to verify
actual Openfront server membership instead of just a linked account — either by
reading a dedicated membership flag returned by getUserMe() (e.g.,
me.user.isOpenfrontMember or similar) or by adding a new API call that checks
membership (e.g., checkDiscordServerMembership(userId) or a backend endpoint)
and set this.hasDiscord only when that membership check succeeds; ensure you
adjust any downstream UI usage to rely on the membership check rather than
me.user.discord.

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Feb 3, 2026
@internet-addict-xyz
Copy link
Author

Thanks! Though, them having a logged-in Discord account doesn't mean they are member of the Openfront discord server, or does it?

Yeah... I’m dumbass. Oops, sorry.

@github-project-automation github-project-automation bot moved this from Development to Complete in OpenFront Release Management Feb 3, 2026
@VariableVince
Copy link
Contributor

Thanks! Though, them having a logged-in Discord account doesn't mean they are member of the Openfront discord server, or does it?

Yeah... I’m dumbass. Oops, sorry.

No, mistakes happen, thanks again

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

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Don't show "join discord" if we know the account is already on our server

2 participants