diff --git a/src/Discord.Net/Collections/Channels.cs b/src/Discord.Net/Collections/Channels.cs index 5f0a681db..32549e708 100644 --- a/src/Discord.Net/Collections/Channels.cs +++ b/src/Discord.Net/Collections/Channels.cs @@ -41,21 +41,27 @@ namespace Discord.Collections internal Channel this[string id] => Get(id); - internal IEnumerable Find(string serverId, string name) + internal IEnumerable Find(string serverId, string name, string type = null) { if (serverId == null) throw new ArgumentNullException(nameof(serverId)); + IEnumerable result; if (name.StartsWith("#")) { string name2 = name.Substring(1); - return this.Where(x => x.ServerId == serverId && + result = this.Where(x => x.ServerId == serverId && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) || string.Equals(x.Name, name2, StringComparison.OrdinalIgnoreCase)); } else { - return this.Where(x => x.ServerId == serverId && + result = this.Where(x => x.ServerId == serverId && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)); } + + if (type != null) + result = result.Where(x => x.Type == type); + + return result; } } } diff --git a/src/Discord.Net/DiscordClient.Cache.cs b/src/Discord.Net/DiscordClient.Cache.cs index 1416de4cb..3be2b2c49 100644 --- a/src/Discord.Net/DiscordClient.Cache.cs +++ b/src/Discord.Net/DiscordClient.Cache.cs @@ -8,10 +8,10 @@ namespace Discord public Channel GetChannel(string id) => _channels[id]; /// Returns all channels with the specified server and name. /// Name formats supported: Name and #Name. Search is case-insensitive. - public IEnumerable FindChannels(Server server, string name) => _channels.Find(server?.Id, name); + public IEnumerable FindChannels(Server server, string name, string type = null) => _channels.Find(server?.Id, name, type); /// Returns all channels with the specified server and name. /// Name formats supported: Name and #Name. Search is case-insensitive. - public IEnumerable FindChannels(string serverId, string name) => _channels.Find(serverId, name); + public IEnumerable FindChannels(string serverId, string name, string type = null) => _channels.Find(serverId, name, type); /// Returns the user with the specified id, along with their server-specific data, or null if none was found. public Member GetMember(string serverId, User user) => _members[user?.Id, serverId];