Browse Source

Fixes #414

tags/1.0-rc
RogueException 8 years ago
parent
commit
2778d0bdbe
2 changed files with 12 additions and 6 deletions
  1. +4
    -4
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  2. +8
    -2
      src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs

+ 4
- 4
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -1561,7 +1561,7 @@ namespace Discord.WebSocket

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);
if (data.UserId == CurrentUser.Id)
{
@@ -1570,7 +1570,7 @@ namespace Discord.WebSocket
}
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);
}

@@ -1583,12 +1583,12 @@ namespace Discord.WebSocket
{
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);
}
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);
}
user = groupChannel.GetUser(data.UserId);


+ 8
- 2
src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs View File

@@ -8,6 +8,8 @@ namespace Discord.WebSocket
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct SocketVoiceState : IVoiceState
{
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, false, false, false, false, false);

[Flags]
private enum Flags : byte
{
@@ -30,7 +32,7 @@ namespace Discord.WebSocket
public bool IsSelfMuted => (_voiceStates & Flags.SelfMuted) != 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;
VoiceSessionId = sessionId;
@@ -40,13 +42,17 @@ namespace Discord.WebSocket
voiceStates |= Flags.SelfMuted;
if (isSelfDeafened)
voiceStates |= Flags.SelfDeafened;
if (isMuted)
voiceStates |= Flags.Muted;
if (isDeafened)
voiceStates |= Flags.Deafened;
if (isSuppressed)
voiceStates |= Flags.Suppressed;
_voiceStates = voiceStates;
}
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";


Loading…
Cancel
Save