diff --git a/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs b/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs index 19657d9bb..c0663e924 100644 --- a/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs +++ b/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs @@ -14,7 +14,7 @@ namespace Discord.WebSocket [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class Guild : IGuild, IUserGuild { - private ConcurrentDictionary _channels; + private ConcurrentHashSet _channels; private ConcurrentDictionary _members; private ConcurrentDictionary _roles; private ulong _ownerId; @@ -71,11 +71,11 @@ namespace Discord.WebSocket /// Gets the embed channel for this guild. public IChannel EmbedChannel => GetChannel(_embedChannelId.GetValueOrDefault(0)); //TODO: Is this text or voice? /// Gets a collection of all channels in this guild. - public IEnumerable Channels => _channels.Select(x => x.Value); + public IEnumerable Channels => _channels.Select(x => Discord.GetChannel(x) as GuildChannel); /// Gets a collection of text channels in this guild. - public IEnumerable TextChannels => _channels.Select(x => x.Value).OfType(); + public IEnumerable TextChannels => _channels.Select(x => Discord.GetChannel(x) as TextChannel); /// Gets a collection of voice channels in this guild. - public IEnumerable VoiceChannels => _channels.Select(x => x.Value).OfType(); + public IEnumerable VoiceChannels => _channels.Select(x => Discord.GetChannel(x) as VoiceChannel); /// Gets a collection of all roles in this guild. public IEnumerable Roles => _roles?.Select(x => x.Value) ?? Enumerable.Empty(); /// Gets a collection of all users in this guild. @@ -185,9 +185,8 @@ namespace Discord.WebSocket /// Gets the channel in this guild with the provided id, or null if not found. public GuildChannel GetChannel(ulong id) { - GuildChannel channel; - if (_channels.TryGetValue(id, out channel)) - return channel; + if (_channels.ContainsKey(id)) + return Discord.GetChannel(id) as GuildChannel; return null; } /// Creates a new text channel.