Fixed internal nullref on voicestate change
This commit is contained in:
@@ -430,13 +430,13 @@ namespace Discord.WebSocket
|
||||
var after = SocketVoiceState.Create(voiceChannel, model);
|
||||
_voiceStates[model.UserId] = after;
|
||||
|
||||
if (before.VoiceChannel?.Id != after.VoiceChannel?.Id)
|
||||
if (_audioClient != null && before.VoiceChannel?.Id != after.VoiceChannel?.Id)
|
||||
{
|
||||
if (model.UserId == CurrentUser.Id)
|
||||
RepopulateAudioStreams();
|
||||
else
|
||||
{
|
||||
_audioClient?.RemoveInputStream(model.UserId); //User changed channels, end their stream
|
||||
_audioClient.RemoveInputStream(model.UserId); //User changed channels, end their stream
|
||||
if (CurrentUser.VoiceChannel != null && after.VoiceChannel?.Id == CurrentUser.VoiceChannel?.Id)
|
||||
_audioClient.CreateInputStream(model.UserId);
|
||||
}
|
||||
@@ -574,8 +574,6 @@ namespace Discord.WebSocket
|
||||
}
|
||||
|
||||
internal void RepopulateAudioStreams()
|
||||
{
|
||||
if (_audioClient != null)
|
||||
{
|
||||
_audioClient.ClearInputStreams(); //We changed channels, end all current streams
|
||||
if (CurrentUser.VoiceChannel != null)
|
||||
@@ -587,7 +585,6 @@ namespace Discord.WebSocket
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => Name;
|
||||
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||
|
||||
Reference in New Issue
Block a user