Added channel type parameter to FindChannels
This commit is contained in:
@@ -41,21 +41,27 @@ namespace Discord.Collections
|
||||
|
||||
internal Channel this[string id] => Get(id);
|
||||
|
||||
internal IEnumerable<Channel> Find(string serverId, string name)
|
||||
internal IEnumerable<Channel> Find(string serverId, string name, string type = null)
|
||||
{
|
||||
if (serverId == null) throw new ArgumentNullException(nameof(serverId));
|
||||
|
||||
IEnumerable<Channel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ namespace Discord
|
||||
public Channel GetChannel(string id) => _channels[id];
|
||||
/// <summary> Returns all channels with the specified server and name. </summary>
|
||||
/// <remarks> Name formats supported: Name and #Name. Search is case-insensitive. </remarks>
|
||||
public IEnumerable<Channel> FindChannels(Server server, string name) => _channels.Find(server?.Id, name);
|
||||
public IEnumerable<Channel> FindChannels(Server server, string name, string type = null) => _channels.Find(server?.Id, name, type);
|
||||
/// <summary> Returns all channels with the specified server and name. </summary>
|
||||
/// <remarks> Name formats supported: Name and #Name. Search is case-insensitive. </remarks>
|
||||
public IEnumerable<Channel> FindChannels(string serverId, string name) => _channels.Find(serverId, name);
|
||||
public IEnumerable<Channel> FindChannels(string serverId, string name, string type = null) => _channels.Find(serverId, name, type);
|
||||
|
||||
/// <summary> Returns the user with the specified id, along with their server-specific data, or null if none was found. </summary>
|
||||
public Member GetMember(string serverId, User user) => _members[user?.Id, serverId];
|
||||
|
||||
Reference in New Issue
Block a user