Skip to main content
Wiki integration commands connect Discord users with their Fandom accounts and sync roles based on wiki permissions. Link your Discord account to your Fandom wiki account.
fandomusername
String
required
Your username on Fandom (case-sensitive)

Linking Process

1

Username Verification

Queries MediaWiki API to verify the username exists
// From link.ts:75
const userQueryUrl = `https://alter-ego.fandom.com/api.php?action=query&format=json&list=users&ususers=${encodeURIComponent(fandomUsernameInput)}`;
2

Discord Handle Check

Fetches user profile data to verify Discord handle is set
// From link.ts:139
const userProfileUrl = `https://alter-ego.fandom.com/wikia.php?controller=UserProfile&method=getUserData&format=json&userId=${fandomUserId}`;
3

Handle Verification

Compares Discord handle on Fandom with current Discord username
4

Confirmation

60-second confirmation button to finalize linking
5

Role Sync

Automatically grants Discord roles based on Fandom groups

Discord Handle Setup

If Discord handle is not set or mismatched, users are directed to Special:VerifyUser:
// From link.ts:151
const verifyUrl = `https://alter-ego.fandom.com/wiki/Special:VerifyUser/${encodeURIComponent(canonicalFandomUsername)}?user=${encodeURIComponent(interaction.user.username)}&c=wb&ch=verify-me&useskin=fandomdesktop`;

Role Mapping

Fandom groups are automatically mapped to Discord roles:
  • sysop → Alterministrator
  • bureaucrat → Bureaucrat
  • content-moderator → Content Moderator
  • threadmoderator → Discussions Moderator
Top 5 weekly contributors automatically receive the Top Contributors role

Important Notes

Linking is permanent and cannot be undone without administrator intervention. A confirmation step prevents accidental linking.
The linking check is case-sensitive for usernames but case-insensitive for Discord handle matching.

Check if a user is linked and synchronize their roles.
user
User
User to check (defaults to command executor)

Functionality

For users with an existing link:
  1. Displays link information (Discord user, Fandom username, link date)
  2. Fetches current Fandom groups from MediaWiki API
  3. Synchronizes Discord roles based on groups
  4. Checks top contributor status
  5. Shows all granted/removed roles

Role Synchronization

// From checklink.ts:136-142
const roleResult = await FandomRoleManager.manageFandomRoles(
  targetMember,
  fandomGroups,
  interaction.guild,
  existingLink.fandomUsername,
);
grantedRoleNames = roleResult.grantedRoleNames;
failedRoleNames = roleResult.failedRoleNames;
The sync process:
  • Grants roles for groups the user has
  • Removes roles for groups the user no longer has
  • Reports any failures (missing roles, permission errors)

Top Contributor Check

// From checklink.ts:152-156
topContributorResult =
  await TopContributorsManager.manageTopContributorRole(
    targetMember,
    existingLink.fandomUsername,
  );
Fetches weekly contribution data and:
  • Grants role if user is in top 5
  • Shows current rank
  • Removes role if no longer in top 5

Display Format

Embed shows:
  • Discord username and tag
  • Fandom username
  • Link timestamp
  • Synchronized roles (with role mentions)
  • Top contributor rank (if applicable)
  • Fandom groups
  • Any errors encountered

/syncroles

Manually synchronize all linked users’ roles.
This command requires specific permissions. Check the role permissions system for access requirements.

Sync Process

1

Fetch All Links

Retrieves all Discord-Fandom links from the database
2

Process Each User

For each linked user:
  • Fetch current Fandom groups
  • Update Discord roles
  • Check top contributor status
  • Log any errors
3

Wiki Sync

Sends role data to wiki for cross-platform integration
4

Report Results

Displays statistics and any errors encountered

Implementation

// From syncroles.ts:51-56
const result = await TopContributorsManager.syncAllTopContributorRoles(
  interaction.guild,
);
const wikiSyncResult = await WikiRoleSyncManager.syncRolesToWiki(
  interaction.guild,
);

Statistics Reported

  • Linked Users Processed - Total users checked
  • Roles Granted - New roles added
  • Roles Removed - Outdated roles removed
  • Errors Encountered - Failed operations
  • Wiki Sync Status - Success/failure of wiki integration

Error Handling

Errors are logged and displayed in the response:
// From syncroles.ts:87-97
if (result.errors.length > 0) {
  const errorSample = result.errors.slice(0, 3).join("\n");
  const additionalErrors =
    result.errors.length > 3
      ? `\n... and ${result.errors.length - 3} more errors`
      : "";

  embed.addFields({
    name: "⚠️ ERRORS ENCOUNTERED",
    value: `\`\`\`${errorSample}${additionalErrors}\`\`\``,
  });
}

/trivia

Fetch random trivia facts from wiki pages.
game
String (Choice)
Wiki to fetch trivia fromOptions:
  • ALTER EGO (default)
  • Tower Defense Simulator

Wiki Sources

Source: https://alter-ego.fandom.com/wiki/ALTERPEDIA/DYK?action=rawColor: #e61f24 (ALTER EGO red)Footer: “Verily, I have drawn forth this knowledge from the annals of ALTERPEDIA.”

Trivia Format

Facts are stored in wiki pages using <option> tags:
<option>Fact text here with [[wiki links]] and '''formatting'''</option>

Processing

// From trivia.ts:8-12
function cleanWikitext(text: string): string {
  text = text.replace(/\[\[([^|\]]+\|)?([^\]]+)\]\]/g, "$2"); // Remove wiki links
  text = text.replace(/'''([^']+)'''/g, "$1"); // Remove bold
  text = text.replace(/''([^']+)''/g, "$1"); // Remove italic
  return text;
}

Example Response

📚 Did you know that in ALTER EGO:

The Watcher is the only character who can see through the Fourth Wall, making them aware of the player's existence.

Verily, I have drawn forth this knowledge from the annals of ALTERPEDIA.

Error Handling

If trivia fetch fails:
  • Logs error to console
  • Shows ephemeral error message
  • Suggests trying again later
Trivia facts are randomly selected from all available options each time the command is used.

API Integration Details

MediaWiki API Queries

All wiki integration uses the MediaWiki Action API:
// User query
`https://alter-ego.fandom.com/api.php?action=query&format=json&list=users&ususers=${username}&usprop=groups|gender|registration|editcount`

// User profile  
`https://alter-ego.fandom.com/wikia.php?controller=UserProfile&method=getUserData&format=json&userId=${userId}`

Response Interfaces

interface FandomUserQueryUser {
  userid: number;
  name: string;
  missing?: string;
  groups?: string[];
  editcount?: number;
  registration?: string;
  gender?: string;
}

interface FandomUserProfileData {
  id: number;
  username: string;
  discordHandle?: string;
}

Top Contributors API

Fetches weekly contribution data to determine top 5 contributors for role assignment.
All wiki integration commands require the bot to be in a guild context. They cannot be used in DMs.

/family

Manage family relationships and view family trees with visual rendering.

Subcommands

tree

View a visual family tree diagram.
user
User
The user whose family tree to view (defaults to yourself)
Generates a visual family tree using Canvas with:
  • User avatars
  • Relationship lines
  • Generational layout
  • PNG image output

profile

View family relationships as a text list.
user
User
The user whose family profile to view (defaults to yourself)
Lists:
  • Spouse (if married)
  • Parents (if any)
  • Children (if any)
  • Total family member count

marry

Propose marriage to another user (requires mutual consent).
user
User
required
The user you want to marry
Requirements:
  • Neither user can already be married
  • Both users must accept within 60 seconds
  • Cannot marry yourself
  • Cannot marry bots

divorce

Divorce your current spouse.
user
User
required
Your spouse to divorce
Requirements:
  • Must be married to the specified user
  • Removes spouse relationship immediately
  • No confirmation required

adopt

Adopt another user as your child (requires mutual consent).
user
User
required
The user you want to adopt
Requirements:
  • User cannot already have parents
  • If you’re married, your spouse must also consent
  • Both parties must accept within 60 seconds
  • Cannot adopt yourself or bots

disown

Remove a parent-child relationship.
user
User
required
The family member to disown (your child or your parent)
Behavior:
  • Parents can disown children
  • Children can disown parents
  • Removes relationship immediately
  • No confirmation required

Family Tree Renderer

// From familyTreeRenderer.ts
- Uses Canvas for image generation
- Displays user avatars in circular frames
- Draws relationship lines between family members
- Arranges members by generation (grandparentsparentschildren)
- Maximum 50 family members displayed

Data Storage

Family relationships are stored in JSON files:
  • Each guild has separate family data
  • Relationships persist across bot restarts
  • Stored at ./family-data-{guildId}.json
The family system is entirely separate from Fandom wiki integration. It’s a fun social feature for server members.
Family relationships are server-specific. If a user is in multiple servers with the bot, they can have different families in each.

Build docs developers (and LLMs) love