getOrCreatePlayerNode method

Node getOrCreatePlayerNode(
  1. Snowflake guildId
)

Attempts to get the node containing a player for a specific guild id

if the player doesn't exist, then the best node is retrieved and the player created

Implementation

Node getOrCreatePlayerNode(Snowflake guildId) {
  final nodePreview = this._nodeLocations.containsKey(guildId)
      ? this._nodes[_nodeLocations[guildId]]
      : this.bestNode;

  final node = nodePreview ?? this.bestNode;

  if (!node._players.containsKey(guildId)) {
    node.createPlayer(guildId);
  }

  return node;
}