예제 #1
0
        /// <summary>
        /// Disconnects from the <paramref name="voiceChannel"/>.
        /// </summary>
        /// <param name="voiceChannel">Connected voice channel.</param>
        public async Task DisconnectAsync(IVoiceChannel voiceChannel)
        {
            if (!Players.TryRemove(voiceChannel.GuildId, out _))
            {
                return;
            }

            await voiceChannel.DisconnectAsync().ConfigureAwait(false);

            var destroyPayload = new DestroyPayload(voiceChannel.GuildId);
            await _socketHelper.SendPayloadAsync(destroyPayload);
        }
예제 #2
0
        /// <summary>
        /// Disconnects from the <paramref name="voiceChannel"/>.
        /// </summary>
        /// <param name="voiceChannel">Connected voice channel.</param>
        public async Task DisconnectAsync(IVoiceChannel voiceChannel)
        {
            if (!Players.TryRemove(voiceChannel.GuildId, out LavaPlayer player))
            {
                return;
            }

            await player.DisposeAsync();

            await voiceChannel.DisconnectAsync();

            var destroyPayload = new DestroyPayload(voiceChannel.GuildId);
            await _socketHelper.SendPayloadAsync(destroyPayload);
        }
예제 #3
0
        /// <inheritdoc />
        public async ValueTask DisposeAsync()
        {
            await StopAsync()
            .ConfigureAwait(false);

            var payload = new DestroyPayload(VoiceChannel.GuildId);
            await _lavaSocket.SendAsync(payload)
            .ConfigureAwait(false);

            Queue.Clear();
            Queue        = default;
            Track        = null;
            VoiceChannel = null;
            PlayerState  = PlayerState.None;
        }
예제 #4
0
        /// <summary>
        /// Disposes <see cref="LavaPlayer"/>, sends a stop and destroy request to Lavalink server and disconnects from <see cref="VoiceChannel"/>.
        /// </summary>
        public async ValueTask DisposeAsync()
        {
            IsPlaying = false;
            Queue.Clear();
            Queue        = null;
            CurrentTrack = null;
            var stopPayload    = new StopPayload(VoiceChannel.GuildId);
            var destroyPayload = new DestroyPayload(VoiceChannel.GuildId);
            await _socketHelper.SendPayloadAsync(stopPayload);

            await _socketHelper.SendPayloadAsync(destroyPayload);

            await VoiceChannel.DisconnectAsync().ConfigureAwait(false);

            GC.SuppressFinalize(this);
        }
예제 #5
0
        /// <inheritdoc />
        public async ValueTask DisposeAsync()
        {
            await StopAsync()
            .ConfigureAwait(false);

            var payload = new DestroyPayload(VoiceChannel.GuildId);
            await _sock.SendAsync(payload)
            .ConfigureAwait(false);

            GC.SuppressFinalize(this);

            Queue.Clear();
            Queue        = default;
            Track        = null;
            VoiceChannel = null;
            PlayerState  = PlayerState.Disconnected;
        }