The bot keeps your Discord server’s role hierarchy in perfect sync with Faceit. Level roles are created on demand with the correct colour, assigned on verification, and updated after every finished match. Club membership roles arrive via Faceit Hub webhooks the moment they are granted or revoked on the platform. Every piece of role logic lives inDocumentation 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.
services/roles.js and is wired together in webhooks/faceit.js and events/ready.js.
Level Roles — Faceit Level 1 through Faceit Level 10
Auto-creation with getOrCreateLevelRole()
guild.roles.cache for a role named Faceit Level <N>. If the role does not exist it calls guild.roles.create() with the appropriate colour from LEVEL_ROLE_COLORS (defined in config/index.js).
Color Table
| Role | Levels | Hex |
|---|---|---|
Faceit Level 1 – Faceit Level 3 | 1, 2, 3 | #8C8C8C grey |
Faceit Level 4 – Faceit Level 7 | 4, 5, 6, 7 | #15C253 green |
Faceit Level 8 – Faceit Level 9 | 8, 9 | #FF9E00 orange |
Faceit Level 10 | 10 | #FF3E3E red |
Syncing a Member — syncMemberLevelRole()
- Fetches the guild member.
- Calls
getOrCreateLevelRole(guild, level)to obtain the target role. - Iterates levels 1–10, building a list of all other
Faceit Level Xroles that the member currently holds. - Removes those roles in a single
member.roles.remove(rolesToRemove)call. - Adds the new target role if the member does not already have it.
syncMemberLevelRole() is triggered in three scenarios:
- On verification — immediately after
db.linkAccounts()ifautoRoleSyncis enabled. - On
/sincronizar_fc— when a player manually requests a sync. - After a finished match —
syncPlayerLevels()inwebhooks/faceit.jsruns it for every player in both rosters.
Detecting the Skill Level — getPlayerSkillLevel()
Club / Special Roles
Club roles represent membership tiers in the Faceit Hub. They are defined inconfig/index.js in the CLUB_ROLES_MAP object, which maps Faceit role UUIDs to Discord role names:
| Faceit UUID | Discord Role | Hex Color |
|---|---|---|
d79607e7-77b8-4db0-9abf-c2592820066c | EXTREME | #FF0000 |
f6b04720-3908-4933-9555-f61e63bf420b | EXTREME BAJOS | #D35400 |
dfb94a9b-b17f-4f8e-ace7-6d4863b2ea69 | PREMIUM | #FFD700 |
38d0142f-04da-4130-8df6-c5d801ff5c3e | PLUS | #00BFFF |
Webhook-Driven Role Events
Thehub_user_role_added and hub_user_role_removed webhook events call handleRoleEvent() in webhooks/faceit.js. The flow:
Look up the Faceit player
roleData.user_id is used to call db.getDiscordIdByFaceitId() — no Discord ID means the player is unverified and the event is skipped.Resolve the Discord role
getOrCreateSpecialRole(guild, roleName) finds the role in guild.roles.cache (case-insensitive) or creates it with the colour from SPECIAL_ROLE_COLORS.Auto-create with getOrCreateSpecialRole()
roleName.toUpperCase()). If the role does not exist it is created with the colour from SPECIAL_ROLE_COLORS. This means you never need to manually create Club roles — they appear the first time a webhook fires.
Removing All Roles — removeAllFaceitRoles()
Used by /desvincular_fc to cleanly strip every Faceit-related role when unlinking:
Faceit Level 1 through Faceit Level 10 plus the four special roles (EXTREME, EXTREME BAJOS, PREMIUM, PLUS), collects those the member actually has, and removes them in one batched call. Returns the count of removed roles.
Automatic 12-Hour Bulk Sync
Every 12 hours (events/ready.js), syncAllUserRoles() iterates every document in the faceit_users Firestore collection and:
- Fetches the current Faceit profile via
fetchFaceitPlayerById(). - Calls
syncMemberLevelRole()with the fresh level. - Writes the updated level and ELO back to Firestore via
db.updatePlayerStats().
setTimeout(resolve, 150)) is inserted between each user to respect Faceit API rate limits. The sync is silently skipped if autoRoleSync is false in settings.
Feature Flag
| Flag | Effect |
|---|---|
autoRoleSync | Master switch for all role assignment — level roles on link/sync, Club roles on webhook events, and the 12-hour scheduled bulk sync |