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.

Every significant behavior in the Discord Faceit Hub Bot is gated behind a feature flag. This lets you turn off individual features — like voice channel automation or a specific slash command — without redeploying the bot or touching code. Flags are stored in Firestore and checked at runtime with a 30-second memory cache.

How Feature Flags Work

Feature flag state is stored in the faceit_configsettings Firestore document. The featureFlags.js utility reads this document and caches the result in memory:
const CACHE_TTL_MS = 30 * 1000; // 30 seconds
The primary function for checking flags is isFeatureEnabled(featureKey, guildId):
export async function isFeatureEnabled(featureKey, guildId = null) {
  // 1. If a guildId is provided, check guild-specific settings first
  if (guildId) {
    const guildSettings = await db.getGuildSettings(guildId);
    if (guildSettings && guildSettings[featureKey] !== undefined) {
      return guildSettings[featureKey] === true;
    }
  }
  // 2. Fall back to global settings
  const settings = await getSettings();
  if (featureKey.startsWith('command_') && settings[featureKey] === undefined) {
    return true; // commands default to enabled if not explicitly set
  }
  return settings[featureKey] === true;
}
If a guild has a per-guild setting for a flag (via db.getGuildSettings(guildId)), it takes precedence over the global settings document. This means you can disable a feature for one server without affecting others. Guild-scoped settings are written by the admin panel when you toggle a flag with a specific guild selected.

Default Settings

The getDefaultSettings() function defines what the bot uses when no Firestore document exists yet:
export function getDefaultSettings() {
  return {
    autoWelcomeDm: true,
    autoRoleSync: true,
    autoVoiceChannels: true,
    autoMovePlayers: true,
    matchAnnouncements: true,
    serverStatusAnnouncements: true,
    liveMatchPanel: true,
    webhookValidation: false,
    adminCallNotifications: true,
    adminRoleName: 'ADMIN',
    matchTimeoutMinutes: 120,
    command_mixton_listo: true,
    command_mixton_no_listo: true,
  };
}
Note that webhookValidation defaults to false — signature validation is opt-in to simplify initial setup.

Flag Reference

Automation Flags

KeyDefaultDescription
autoWelcomeDmtrueSend a welcome DM embed to new members who link their Faceit account
autoRoleSynctrueSync Faceit level and club roles automatically on link and after match finish
autoVoiceChannelstrueCreate temporary voice channels for each team when a match starts
autoMovePlayerstrueAuto-move verified players to their match voice channel on match start
matchAnnouncementstruePost match status embeds (configuring / started / finished / cancelled) to the matches channel
serverStatusAnnouncementstruePost a LATAM server status embed to the status channel on match start
liveMatchPaneltrueMaintain a pinned live match panel embed in the matches channel, updated on every match event

Security Flag

KeyDefaultDescription
webhookValidationfalseValidate the x-faceit-signature / x-webhook-signature header on incoming Faceit webhooks against FACEIT_WEBHOOK_SECRET
Leave webhookValidation set to false during initial setup and testing. Once your FACEIT_WEBHOOK_SECRET env var is set and you have confirmed that real Faceit webhooks are arriving correctly, enable this flag in the admin panel to reject any unsigned or spoofed webhook payloads.

Notification Flag

KeyDefaultDescription
adminCallNotificationstrueEnable support call alerts — pings the admin alerts channel when a player requests support

Command Flags

Each slash command can be individually disabled. When a command flag is false, the bot returns a 403 response to that interaction.
KeyDefaultDiscord Command
command_verificartrue/verificar_fc — link Discord to Faceit account
command_statstrue/stats — show player stats by Faceit nickname
command_leaderboardtrue/leaderboard — show hub season leaderboard
command_sincronizartrue/sincronizar_fc — manually re-sync roles
command_desvinculartrue/desvincular_fc — unlink account
command_partidastrue/partidas — show active matches
command_infotrue/info — show bot/hub information
command_mixton_listotrue/mixton_listo — register as ready for a Mixton draft
command_mixton_no_listotrue/mixton_no_listo — remove yourself from the Mixton draft queue

Toggling Flags

Via Admin Panel

  1. Navigate to https://your-domain/admin
  2. Open the Features tab
  3. Click any toggle to immediately enable or disable that flag
The panel calls POST /api/admin/features/:key?guildId=<id> with body { "enabled": true } or { "enabled": false }. The change is written to Firestore and the in-memory cache invalidates automatically within 30 seconds.

Via API

curl -X POST https://your-domain/api/admin/features/autoVoiceChannels \
  -H "Content-Type: application/json" \
  -H "Cookie: admin_token=<your-jwt>" \
  -d '{ "enabled": false }'
Include ?guildId=<guild-id> to scope the change to a specific guild.

Via Firestore Directly

Open the Firestore console, navigate to faceit_configsettings, and set any flag key to true or false. The change propagates to the bot within 30 seconds (next cache expiry). For per-guild overrides, find the guild’s settings document in guild_settings/<guildId> and set the key there.

Cache Invalidation

The settings cache can be invalidated immediately without waiting for the TTL by calling invalidateSettingsCache():
export function invalidateSettingsCache() {
  cachedSettings = null;
  lastFetch = 0;
}
This is called automatically by the admin API routes after any flag toggle, ensuring the bot picks up changes on the very next feature check.

Build docs developers (and LLMs) love