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.

/crear_sala orchestrates a complete manual match setup entirely within Discord — no Faceit room is created. It scoops 10 players out of a voice channel, runs an exhaustive combinatorial ELO-balance algorithm across all C(10,5) = 252 possible team splits, creates two private temporary voice channels named 🔊 Equipo A (Manual) and 🔊 Equipo B (Manual), moves each player to their assigned channel, posts a match-announcement embed with result buttons, and records the match in Firestore. When a match announcement message is successfully posted, each participant also receives a DM with their team assignment.

Syntax

/crear_sala [canal_voz:<VoiceChannel>]

Parameters

canal_voz
voice channel
The source voice channel from which to pull the 10 players. If omitted, the bot tries the command caller’s current voice channel first, then falls back to the configured DISCORD_WAITING_ROOM_CHANNEL_ID. Must be a GuildVoice channel — stage channels are not accepted.

Required Permissions

  • The caller must be in a voice channel or must specify canal_voz explicitly.
  • The bot requires MoveMembers (and ManageChannels / Connect / Speak) in the target category to create and move players into the temporary channels.
You need at least 10 players present in the source voice channel when the command is executed. If fewer than 10 are found, the bot returns an error with the current count and takes no further action.

Behavior

1 — Source Channel Resolution

The bot checks, in order:
  1. canal_voz option (if provided).
  2. The caller’s current voice channel (interaction.member.voice.channel).
  3. config.discordWaitingRoomChannelId fetched from guild config.
If none of these resolves to a GuildVoice channel, the command fails.

2 — Player Data Collection

For every member in the source channel, the bot calls db.getFullUser(memberId, guildId). Linked players contribute their actual faceit_elo and faceit_level; unlinked players receive default values of ELO 1000 / Level 3. Linked players are prioritised: the list is sorted [...linkedPlayers, ...unlinkedPlayers] before the first 10 are selected.

3 — ELO Balancing Algorithm

// Evaluates all C(10,5) = 252 combinations
// Picks the split with the minimum absolute ELO difference
function balanceTeams(players) { … }
The algorithm iterates all 252 index combinations for a 5-player Team A subset, computes the summed ELO of both sides, records the split with the smallest Math.abs(eloA - eloB), and returns { teamA, teamB, diff }.

4 — Private Voice Channel Creation

Two channels are created via guild.channels.create() with ChannelType.GuildVoice in the same category as the source channel:
ChannelName
Team A🔊 Equipo A (Manual)
Team B🔊 Equipo B (Manual)
Both channels deny Connect to @everyone. The bot grants itself ViewChannel, Connect, Speak, ManageChannels, and MoveMembers. Each assigned player is granted Connect and Speak for their respective channel only — making both channels effectively private.

5 — Player Movement

All 10 players are moved (member.voice.setChannel()) to their assigned voice channels. Original voice states are saved in originalVoiceStates so players can be returned when the match ends.

6 — Announcement Embed & Buttons

A match-announcement embed is posted to DISCORD_MATCHES_CHANNEL_ID:
  • Lists both rosters with Discord mentions, Faceit nicknames, and levels.
  • Includes three action buttons:
    ButtonCustom ID patternStyle
    🏆 Ganó Equipo Amanual_match_win_a_<matchId>Success (green)
    🏆 Ganó Equipo Bmanual_match_win_b_<matchId>Success (green)
    ❌ Cancelarmanual_match_cancel_<matchId>Danger (red)
The match creator or any admin can click these buttons. On result, players are moved back to their original channels, the temporary voice channels are deleted, and the outcome is recorded in match history.

7 — Player DMs

If the announcement message was posted successfully, each of the 10 players receives a DM embed confirming:
  • Which team they are on (Equipo A or Equipo B).
  • A voice channel mention for their private channel.
  • A link to the announcement message in the matches channel.
DM failures are logged as warnings but do not abort the command. DMs are skipped entirely if DISCORD_MATCHES_CHANNEL_ID is not configured or the announcement message could not be sent.

8 — Firestore Record

The match is saved via db.addActiveMatch(matchId, matchData, vc1.id, vc2.id, messageId, rosterA, rosterB, originalVoiceStates, guildId) and is immediately visible in /partidas. A unique matchId is generated as manual_<timestamp>_<6-char-random>.

Response

The caller receives an ephemeral confirmation (deferReply({ ephemeral: true })):
✅ ¡Sala creada con éxito! Se crearon los canales temporales y se reubicó a los 10 jugadores.
Canal de anuncios: #partidas

Error Reference

ConditionError message
No valid source voice channel found❌ No se encontró ningún canal de voz de origen.
Fewer than 10 players in the channel❌ Se necesitan al menos 10 jugadores en el canal de voz **X** (actualmente hay N).
Unexpected error❌ Ocurrió un error al intentar crear la sala.
The bot needs the Move Members permission in the voice channel category. Without it, player moves will silently fail and players will remain in the original channel even though they are assigned to a team.
Unlinked players are included in the match but assigned a default ELO of 1000 and level 3. Encourage all participants to run /verificar_fc before using /crear_sala so the balance algorithm works with accurate data.

Build docs developers (and LLMs) love