Skip to content

Commit

Permalink
fix: Fix disconnect from voice channel (Discord.Net)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelobreuer committed Aug 13, 2023
1 parent ca42346 commit 8a3be36
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Lavalink4NET.DiscordNet/DiscordClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ public async ValueTask SendVoiceUpdateAsync(ulong guildId, ulong? voiceChannelId
cancellationToken.ThrowIfCancellationRequested();

var guild = _baseSocketClient.GetGuild(guildId)
?? throw new ArgumentException("Invalid or inaccessible guild: " + guildId, nameof(guildId));
?? throw new ArgumentException($"Invalid or inaccessible guild: {guildId}", nameof(guildId));

if (voiceChannelId.HasValue)
{
var channel = guild.GetVoiceChannel(voiceChannelId.Value)
?? throw new ArgumentException("Invalid or inaccessible voice channel: " + voiceChannelId, nameof(voiceChannelId));
?? throw new ArgumentException($"Invalid or inaccessible voice channel: {voiceChannelId}", nameof(voiceChannelId));

await channel
.ConnectAsync(selfDeaf, selfMute, external: true)
Expand All @@ -205,9 +205,10 @@ await channel
}

// Disconnect from voice channel
// Note: Internally it does not matter which voice channel to disconnect from
await guild
.AudioClient
.StopAsync()
.VoiceChannels.First()
.DisconnectAsync()
.WaitAsync(cancellationToken)
.ConfigureAwait(false);
}
Expand Down

0 comments on commit 8a3be36

Please sign in to comment.