hoshimi
    Preparing search index...

    Class PlayerVoiceState

    Class representing the voice connection and state of a player. PlayerVoiceState

    Index

    Constructors

    Properties

    channelId: string | null = null

    The voice channel id.

    endpoint: string | null = null

    The voice server endpoint.

    player: Player

    Reference to the player structure this voice instance belongs to.

    sessionId: string | null = null

    The voice session id.

    token: string | null = null

    The voice server token.

    Methods

    • Connect the player to its configured voice channel.

      Returns Promise<Player>

      The player structure after connecting.

      const player = manager.getPlayer("guildId");

      if (player) {
      await player.voice.connect();
      }
    • Toggle or set self deaf.

      Parameters

      • selfDeaf: boolean = ...

        Whether to self deafen or not. Defaults to toggling the current state.

      Returns Promise<Player>

      The player structure after updating deafen state.

      const player = manager.getPlayer("guildId");

      if (player) {
      await player.voice.deaf(true);
      }
    • Disconnect the player from voice.

      Returns Promise<Player>

      The player structure after disconnecting.

      const player = manager.getPlayer("guildId");

      if (player) {
      await player.voice.disconnect();
      }
    • Move the player to another voice channel.

      Parameters

      • voiceId: string

        The id of the voice channel to move to.

      Returns Promise<Player>

      The player structure after moving.

      const player = manager.getPlayer("guildId");

      if (player) {
      await player.voice.move("target-voice-channel-id");
      }
    • Toggle or set self mute.

      Parameters

      • selfMute: boolean = ...

        Whether to self mute or not. Defaults to toggling the current state.

      Returns Promise<Player>

      The player structure after updating mute state.

      const player = manager.getPlayer("guildId");

      if (player) {
      await player.voice.mute(true);
      }
    • Merge voice data from Lavalink or gateway updates.

      Parameters

      Returns this

      The current PlayerVoiceState instance after patching.

      const player = manager.getPlayer("guildId");

      if (player) {
      player.voice.patch({
      sessionId: "session-id",
      channelId: "voice-channel-id",
      });
      }
    • Reset all voice connection values.

      Returns this

      The current PlayerVoiceState instance.

      const player = manager.getPlayer("guildId");

      if (player) {
      player.voice.reset();
      }
    • Send a voice state payload to the Discord gateway.

      Parameters

      • options: NullableVoiceChannelUpdate = {}

        The voice state options to update. Only include fields that need to be updated, others will be kept as is.

      Returns Promise<void>

      const player = manager.getPlayer("guildId");

      if (player) {
      await player.voice.setState({
      voiceId: "new-voice-channel-id",
      selfMute: false,
      });
      }
    • Return a valid Lavalink voice payload when all required fields are present.

      Returns { channelId: string; endpoint: string; sessionId: string; token: string } | null

      The Lavalink voice payload or null if required fields are missing.

      • { channelId: string; endpoint: string; sessionId: string; token: string }
        • channelId: string

          The voice channel id.

        • endpoint: string

          The voice server endpoint.

        • sessionId: string

          The voice server session id.

        • token: string

          The voice server token.

      • null
      const player = manager.getPlayer("guildId");

      if (player) {
      const voice = player.voice.toLavalink();
      if (!voice) console.log("Voice payload is incomplete");
      }