Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/VasquezRivero92/Discord_Faceit/llms.txt

Use this file to discover all available pages before exploring further.

Account linking is the foundation of everything the Discord Faceit Hub Bot does. When a player runs /verificar_fc, the bot calls the Faceit Data API v4, validates the player’s CS2 or CS:GO profile, writes a permanent link into the Firestore faceit_users collection, and optionally assigns the correct level role — all in one seamless flow. From that point forward, every match announcement, voice channel, and leaderboard entry can resolve a Faceit player ID directly to a Discord mention.

How /verificar_fc Works

1

Feature flag check

Before anything else, the bot checks the command_verificar feature flag. If an administrator has disabled it, the command exits immediately with an ephemeral error.
2

Link-channel validation

The bot reads DISCORD_LINK_CHANNEL_ID (or the Firestore-overridden discordLinkChannelId setting). That value may contain multiple channel IDs separated by commas, allowing you to designate more than one channel for verification. If the command is used anywhere else, the user receives an ephemeral message listing the allowed channels:
❌ Este comando solo se puede usar en el canal de vinculación: #verificacion
3

Faceit API lookup

fetchFaceitPlayer(nickname) is called against the Faceit Data API v4 endpoint /players?nickname=<nickname>. If the nickname does not exist on Faceit, the bot returns a PLAYER_NOT_FOUND error to the user.
4

Duplicate check

db.getDiscordIdByFaceitId(player.player_id, guildId) is called to ensure the Faceit account is not already linked to another Discord user. If it belongs to the same Discord user, the bot tells them politely; if it belongs to someone else, the link is refused.
5

Skill level and ELO extraction

getPlayerSkillLevel(player) reads player.games.cs2.skill_level first, then falls back to player.games.csgo.skill_level. ELO is extracted from player.games.cs2.faceit_elo with the same CS:GO fallback. If neither game has an active level the command aborts.
6

Firestore write

db.linkAccounts(discordId, player.player_id, player.nickname, skillLevel, elo, guildId) stores the link in the faceit_users collection. An audit entry is also written via db.addLogEntry().
7

Role sync

If the autoRoleSync feature flag is enabled, syncMemberLevelRole(guild, discordId, skillLevel) is called immediately, assigning the correct Faceit Level X role.
8

Success reply + public notification

The user receives an ephemeral confirmation with a link to their Faceit profile. A public message is sent in the link channel so the rest of the server can see the new verification:
✨ ¡El usuario @Player se ha verificado exitosamente con su perfil de Faceit [Nickname] (Nivel 8)! 🎉

In-Memory Player Cache

To avoid hitting the Firestore database on every role check, verified players are stored in a playerCache map (utils/cache.js). The cache entry holds { faceitId, nickname, level } and has a 5-minute TTL. On verification the key is <guildId>_<discordId>; on /sincronizar_fc the key is just <discordId>. Entries are populated on successful verification and on every /sincronizar_fc call.

Automatic Welcome DM

When a new member joins the server (guildMemberAdd event), the bot can automatically send a DM with step-by-step verification instructions if the autoWelcomeDm feature flag is enabled. The DM is generated by createWelcomeEmbed() from services/matchMessages.js and includes:
  • A link to join the Faceit Club
  • Instructions to copy their exact Faceit nickname
  • A mention of the link channel and the /verificar_fc command
The welcome DM uses a customisable template. You can configure welcomeTitle, welcomeDescription, and welcomeColor from the admin panel’s Plantillas de Mensajes section to match your community’s branding.

Syncing Roles Manually — /sincronizar_fc

Any verified player can run /sincronizar_fc at any time to re-fetch their current Faceit level and ELO and update their Discord roles. The command:
  1. Reads the player’s faceit_player_id from db.getFaceitIdByDiscordId().
  2. Calls fetchFaceitPlayerById(faceitPlayerId) to get fresh data from the Faceit API.
  3. Runs syncMemberLevelRole(guild, discordId, skillLevel) to swap roles.
  4. Updates the in-memory playerCache.
  5. Replies with the new level and ELO in an ephemeral embed.
This is also triggered automatically after every finished match (see Role Management) and on the 12-hour scheduled sync.

Unlinking Accounts — /desvincular_fc

Administrators can unlink any verified player using /desvincular_fc @user. The command requires the caller to have the ADMIN role (configurable via ADMIN_ROLE_NAME) and must be used in the designated link channel.

What it does

Calls db.unlinkAccount(targetUser.id, guildId) to remove the Firestore record, then removeAllFaceitRoles(member, guild) to strip all Faceit Level 110 roles plus any Club special roles (EXTREME, EXTREME BAJOS, PREMIUM, PLUS).

Audit log

Every unlink action is recorded with db.addLogEntry('warn', ...) so admins can review it in the Registros de Sistema panel.

Configuration Reference

VariablePurpose
DISCORD_LINK_CHANNEL_IDOne or more channel IDs (comma-separated) where /verificar_fc and /desvincular_fc are allowed
FACEIT_API_KEYFaceit Data API v4 key; without it the command will refuse to run
ADMIN_ROLE_NAMEThe Discord role name that grants access to /desvincular_fc (default: ADMIN)
DISCORD_LINK_CHANNEL_ID supports comma-separated channel IDs, for example 123456789,987654321. All listed channels will be equally valid for /verificar_fc and /desvincular_fc. The bot will mention all of them in the error message if the command is used elsewhere.

Build docs developers (and LLMs) love