private async Task WriteStreamToVoiceChannel(AudioClient audioClient, AudioOutStream discord, MemoryStream memoryStream) { try { await discord.WriteAsync(memoryStream.ToArray(), 0, (int)memoryStream.Length); } finally { await memoryStream.DisposeAsync(); await discord.FlushAsync(); await discord.DisposeAsync(); // Clear current stream audioClient.CurrentStream = null; // Play next AudioOnlyStreamInfo nextSong = audioClient.GetNextSong(); if (nextSong != null) { this.StartStream(youtube, audioClient, nextSong, null); } } }