Fixes #414
This commit is contained in:
@@ -1561,7 +1561,7 @@ namespace Discord.WebSocket
|
|||||||
|
|
||||||
if (data.ChannelId != null)
|
if (data.ChannelId != null)
|
||||||
{
|
{
|
||||||
before = guild.GetVoiceState(data.UserId)?.Clone() ?? new SocketVoiceState(null, null, false, false, false);
|
before = guild.GetVoiceState(data.UserId)?.Clone() ?? SocketVoiceState.Default;
|
||||||
after = guild.AddOrUpdateVoiceState(State, data);
|
after = guild.AddOrUpdateVoiceState(State, data);
|
||||||
if (data.UserId == CurrentUser.Id)
|
if (data.UserId == CurrentUser.Id)
|
||||||
{
|
{
|
||||||
@@ -1570,7 +1570,7 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
before = guild.RemoveVoiceState(data.UserId) ?? new SocketVoiceState(null, null, false, false, false);
|
before = guild.RemoveVoiceState(data.UserId) ?? SocketVoiceState.Default;
|
||||||
after = SocketVoiceState.Create(null, data);
|
after = SocketVoiceState.Create(null, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1583,12 +1583,12 @@ namespace Discord.WebSocket
|
|||||||
{
|
{
|
||||||
if (data.ChannelId != null)
|
if (data.ChannelId != null)
|
||||||
{
|
{
|
||||||
before = groupChannel.GetVoiceState(data.UserId)?.Clone() ?? new SocketVoiceState(null, null, false, false, false);
|
before = groupChannel.GetVoiceState(data.UserId)?.Clone() ?? SocketVoiceState.Default;
|
||||||
after = groupChannel.AddOrUpdateVoiceState(State, data);
|
after = groupChannel.AddOrUpdateVoiceState(State, data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
before = groupChannel.RemoveVoiceState(data.UserId) ?? new SocketVoiceState(null, null, false, false, false);
|
before = groupChannel.RemoveVoiceState(data.UserId) ?? SocketVoiceState.Default;
|
||||||
after = SocketVoiceState.Create(null, data);
|
after = SocketVoiceState.Create(null, data);
|
||||||
}
|
}
|
||||||
user = groupChannel.GetUser(data.UserId);
|
user = groupChannel.GetUser(data.UserId);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace Discord.WebSocket
|
|||||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public struct SocketVoiceState : IVoiceState
|
public struct SocketVoiceState : IVoiceState
|
||||||
{
|
{
|
||||||
|
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, false, false, false, false, false);
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
private enum Flags : byte
|
private enum Flags : byte
|
||||||
{
|
{
|
||||||
@@ -30,7 +32,7 @@ namespace Discord.WebSocket
|
|||||||
public bool IsSelfMuted => (_voiceStates & Flags.SelfMuted) != 0;
|
public bool IsSelfMuted => (_voiceStates & Flags.SelfMuted) != 0;
|
||||||
public bool IsSelfDeafened => (_voiceStates & Flags.SelfDeafened) != 0;
|
public bool IsSelfDeafened => (_voiceStates & Flags.SelfDeafened) != 0;
|
||||||
|
|
||||||
internal SocketVoiceState(SocketVoiceChannel voiceChannel, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isSuppressed)
|
internal SocketVoiceState(SocketVoiceChannel voiceChannel, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed)
|
||||||
{
|
{
|
||||||
VoiceChannel = voiceChannel;
|
VoiceChannel = voiceChannel;
|
||||||
VoiceSessionId = sessionId;
|
VoiceSessionId = sessionId;
|
||||||
@@ -40,13 +42,17 @@ namespace Discord.WebSocket
|
|||||||
voiceStates |= Flags.SelfMuted;
|
voiceStates |= Flags.SelfMuted;
|
||||||
if (isSelfDeafened)
|
if (isSelfDeafened)
|
||||||
voiceStates |= Flags.SelfDeafened;
|
voiceStates |= Flags.SelfDeafened;
|
||||||
|
if (isMuted)
|
||||||
|
voiceStates |= Flags.Muted;
|
||||||
|
if (isDeafened)
|
||||||
|
voiceStates |= Flags.Deafened;
|
||||||
if (isSuppressed)
|
if (isSuppressed)
|
||||||
voiceStates |= Flags.Suppressed;
|
voiceStates |= Flags.Suppressed;
|
||||||
_voiceStates = voiceStates;
|
_voiceStates = voiceStates;
|
||||||
}
|
}
|
||||||
internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model)
|
internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model)
|
||||||
{
|
{
|
||||||
return new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Suppress);
|
return new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => VoiceChannel?.Name ?? "Unknown";
|
public override string ToString() => VoiceChannel?.Name ?? "Unknown";
|
||||||
|
|||||||
Reference in New Issue
Block a user