Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

[Bug]: Changing voice channel throws OperationCancelledException

Open josago97 opened this issue 1 year ago • 0 comments

Check The Docs

  • [X] I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • [X] I verified the issue was caused by Discord.Net.

Check your intents

  • [X] I double checked that I have the required intents.

Description

I've been following the streaming audio library tutorial available here. While the audio streaming, if the bot changes voice channel then the stream is interrupted throwing an OperationCancelledException error. In previous versions this did not happen and was managed correctly.

Version

3.11.0

Working Version

No response

Logs

The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException() at System.Threading.SemaphoreSlim.<WaitUntilCountOrTimeoutAsync>d__31.MoveNext() at Discord.Audio.Streams.BufferedWriteStream.<WriteAsync>d__22.MoveNext() at Discord.Audio.Streams.OpusEncodeStream.<WriteAsync>d__8.MoveNext() at System.IO.Stream.<<CopyToAsync>g__Core|29_0>d.MoveNext()

Sample

using (var ffmpeg = CreateStream(path))
using (var output = ffmpeg.StandardOutput.BaseStream)
using (var discord = client.CreatePCMStream(AudioApplication.Mixed))
{
    await output.CopyToAsync(discord); // OperationCancelledException here
    await discord.FlushAsync();
}

Packages

NET 6.0

josago97 avatar Aug 09 '23 21:08 josago97