Overview
The Fandom Linking feature allows Discord users to link their Discord accounts with their Fandom wiki accounts. Once linked, Aphonos automatically synchronizes Discord roles based on Fandom user groups, edit counts, and top contributor status.How It Works
Verification Flow
The linking process uses Fandom’s API and profile system to verify account ownership:Fandom account lookup
Aphonos queries the MediaWiki API to verify the account exists:This returns the user’s ID, groups, edit count, and registration date.
Discord handle verification
Aphonos fetches the user’s Fandom profile data:The bot compares the Discord handle set in the Fandom profile with the Discord username.
Set Discord handle (if needed)
If Discord handle is missing or mismatched, users are directed to:This special page helps users add/update their Discord handle on Fandom.
Confirmation
After verification, users must click a confirmation button within 60 seconds to complete the link.
Role Synchronization
Fandom Group Roles
Aphonos maps Fandom user groups to Discord roles:- Wiki Staff roles based on Fandom permissions (sysop, content-moderator, etc.)
- Linked role for all verified users
- Staff role for users with any Fandom administrative group
src/utils/roleConstants.ts using the FANDOM_ROLE_MAP.
Edit Count Roles
Edit count roles are granted based on mainspace (namespace 0) contributions:- 250+ Edits: Granted after 250 mainspace edits
- 1000+ Edits: Granted after 1000 mainspace edits
Top Contributor Role
Aphonos integrates with the AEWiki-Recap GitHub repository to track weekly top contributors:- Data is fetched from:
https://raw.githubusercontent.com/Paradoxum-Wikis/AEWiki-Recap/main/data/{year}/recap-{date}.json - Users in the top 5 for the current week receive the “Top Contributor” role
- Roles are automatically updated when users sync their accounts
The top contributor system checks the most recent recap file in the current year’s directory to determine rankings.
Commands
/link
Links your Discord account to a Fandom account.
Parameters:
fandomusername(required): Your exact Fandom username (case-sensitive)
/checklink
Check your current link status and manually sync roles from Fandom.
/syncroles
Manually trigger a role synchronization for your linked account. This updates:
- Fandom group roles
- Edit count roles
- Top contributor status
Data Storage
Linked accounts are stored indata/linked_accounts.json with the following structure:
Implementation Details
Key Files
src/commands/link.ts- Link command implementation (link.ts:1)src/utils/fandomRoleManager.ts- Role synchronization logic (fandomRoleManager.ts:1)src/utils/topContributors.ts- Top contributor management (topContributors.ts:1)src/utils/linkLogger.ts- Link data persistence (linkLogger.ts:1)
API Endpoints Used
-
MediaWiki User Query API
- Endpoint:
https://alter-ego.fandom.com/api.php - Action:
query, List:users - Props:
groups,gender,registration,editcount
- Endpoint:
-
Fandom User Profile API
- Endpoint:
https://alter-ego.fandom.com/wikia.php - Controller:
UserProfile - Method:
getUserData
- Endpoint:
-
User Contributions API
- Endpoint:
https://alter-ego.fandom.com/api.php - Action:
query, List:usercontribs - Namespace:
0(mainspace only)
- Endpoint:
-
GitHub Recap Data
- Endpoint:
https://api.github.com/repos/Paradoxum-Wikis/AEWiki-Recap/contents/data/{year} - Raw data:
https://raw.githubusercontent.com/Paradoxum-Wikis/AEWiki-Recap/main/data/{year}/{file}
- Endpoint:
Role synchronization automatically removes outdated roles when Fandom permissions change, ensuring Discord roles always reflect current wiki status.
Troubleshooting
”Discord handle not found on Fandom profile”
- Visit the Special:VerifyUser link provided by the bot
- Set your Discord username in your Fandom profile
- Wait a few minutes for Fandom to update
- Run
/linkagain