From f1bc568f4599167915d6c361c5818531b0a3cf4c Mon Sep 17 00:00:00 2001 From: Nitix Date: Fri, 26 Aug 2016 00:04:11 +0200 Subject: [PATCH 1/3] Fix Voice Channel being null #174 --- .../Entities/Users/SocketGuildUser.cs | 78 +++++++++++++++++-- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs index 5c957dada..0fa178423 100644 --- a/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs @@ -1,10 +1,11 @@ -using Discord.Rest; +using System; +using Discord.Rest; using Model = Discord.API.GuildMember; using PresenceModel = Discord.API.Presence; namespace Discord.WebSocket { - internal class SocketGuildUser : GuildUser, ISocketUser + internal class SocketGuildUser : GuildUser, ISocketUser, IVoiceState { internal override bool IsAttached => true; @@ -16,11 +17,74 @@ namespace Discord.WebSocket public override Game Game => Presence.Game; public override UserStatus Status => Presence.Status; - public VoiceState? VoiceState => Guild.GetVoiceState(Id); - public bool IsSelfDeafened => VoiceState?.IsSelfDeafened ?? false; - public bool IsSelfMuted => VoiceState?.IsSelfMuted ?? false; - public bool IsSuppressed => VoiceState?.IsSuppressed ?? false; - public SocketVoiceChannel VoiceChannel => VoiceState?.VoiceChannel; + public VoiceState? VoiceState + { + get + { + return Guild.GetVoiceState(Id); + } + } + + public bool IsSelfDeafened + { + get + { + return VoiceState?.IsSelfDeafened ?? false; + } + } + public bool IsSelfMuted + { + get + { + return VoiceState?.IsSelfMuted ?? false; + } + } + public bool IsSuppressed + { + get + { + return VoiceState?.IsSuppressed ?? false; + } + } + public VoiceChannel VoiceChannel + { + get + { + return VoiceState?.VoiceChannel; + } + } + + public bool IsDeafened + { + get + { + return VoiceState?.IsDeafened ?? false; + } + } + + public bool IsMuted + { + get + { + return VoiceState?.IsMuted ?? false; + } + } + + IVoiceChannel IVoiceState.VoiceChannel + { + get + { + return VoiceState?.VoiceChannel; + } + } + + public string VoiceSessionId + { + get + { + return VoiceState?.VoiceSessionId ?? ""; + } + } public SocketGuildUser(SocketGuild guild, SocketGlobalUser user, Model model) : base(guild, user, model) From ab1989ffebd3fa92d8226f4701a871456798edd9 Mon Sep 17 00:00:00 2001 From: Nitix Date: Fri, 26 Aug 2016 00:17:21 +0200 Subject: [PATCH 2/3] Change code formating to follow the style --- .../Entities/Users/SocketGuildUser.cs | 77 +++---------------- 1 file changed, 9 insertions(+), 68 deletions(-) diff --git a/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs index 0fa178423..814d947a8 100644 --- a/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs @@ -17,74 +17,15 @@ namespace Discord.WebSocket public override Game Game => Presence.Game; public override UserStatus Status => Presence.Status; - public VoiceState? VoiceState - { - get - { - return Guild.GetVoiceState(Id); - } - } - - public bool IsSelfDeafened - { - get - { - return VoiceState?.IsSelfDeafened ?? false; - } - } - public bool IsSelfMuted - { - get - { - return VoiceState?.IsSelfMuted ?? false; - } - } - public bool IsSuppressed - { - get - { - return VoiceState?.IsSuppressed ?? false; - } - } - public VoiceChannel VoiceChannel - { - get - { - return VoiceState?.VoiceChannel; - } - } - - public bool IsDeafened - { - get - { - return VoiceState?.IsDeafened ?? false; - } - } - - public bool IsMuted - { - get - { - return VoiceState?.IsMuted ?? false; - } - } - - IVoiceChannel IVoiceState.VoiceChannel - { - get - { - return VoiceState?.VoiceChannel; - } - } - - public string VoiceSessionId - { - get - { - return VoiceState?.VoiceSessionId ?? ""; - } - } + public VoiceState? VoiceState => Guild.GetVoiceState(Id); + public bool IsSelfDeafened => VoiceState?.IsSelfDeafened ?? false; + public bool IsSelfMuted => VoiceState?.IsSelfMuted ?? false; + public bool IsSuppressed => VoiceState?.IsSuppressed ?? false; + public VoiceChannel VoiceChannel => VoiceState?.VoiceChannel; + public bool IsDeafened => VoiceState?.IsDeafened ?? false; + public bool IsMuted => VoiceState?.IsMuted ?? false; + public string VoiceSessionId => VoiceState?.VoiceSessionId ?? ""; + IVoiceChannel IVoiceState.VoiceChannel => VoiceState?.VoiceChannel; public SocketGuildUser(SocketGuild guild, SocketGlobalUser user, Model model) : base(guild, user, model) From 345e429d20ef621e8849bdb55354a1e6259f7a5f Mon Sep 17 00:00:00 2001 From: Nitix Date: Fri, 26 Aug 2016 00:20:19 +0200 Subject: [PATCH 3/3] Remove unused import --- src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs index 814d947a8..0d05c6ae3 100644 --- a/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net/WebSocket/Entities/Users/SocketGuildUser.cs @@ -1,5 +1,4 @@ -using System; -using Discord.Rest; +using Discord.Rest; using Model = Discord.API.GuildMember; using PresenceModel = Discord.API.Presence;