From cbc804777dbbb743b05a4f090295d69cf6eaf532 Mon Sep 17 00:00:00 2001 From: RogueException Date: Mon, 5 Oct 2015 17:36:37 -0300 Subject: [PATCH] Added a few overloads --- src/Discord.Net/Models/Channel.cs | 14 +++++++++----- src/Discord.Net/Models/Member.cs | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Discord.Net/Models/Channel.cs b/src/Discord.Net/Models/Channel.cs index 109758502..53c71eff8 100644 --- a/src/Discord.Net/Models/Channel.cs +++ b/src/Discord.Net/Models/Channel.cs @@ -47,7 +47,7 @@ namespace Discord [JsonIgnore] public User Recipient => _client.Users[RecipientId]; - private string[] _userIds; + /// Returns a collection of the IDs of all users with read access to this channel. public IEnumerable UserIds { get @@ -60,7 +60,10 @@ namespace Discord return _userIds; } } - public IEnumerable Members => UserIds.Select(x => _client.Members[x, ServerId]); + private string[] _userIds; + /// Returns a collection of all users with read access to this channel. + public IEnumerable Members => UserIds.Select(x => _client.Members[x, ServerId]); + /// Returns a collection of all users with read access to this channel. public IEnumerable Users => UserIds.Select(x => _client.Users[x]); /// Returns a collection of the ids of all messages the client has seen posted in this channel. This collection does not guarantee any ordering. @@ -71,7 +74,8 @@ namespace Discord public IEnumerable Messages => _messages.Select(x => _client.Messages[x.Key]); /// Returns a collection of all custom permissions used for this channel. - public PermissionOverwrite[] PermissionOverwrites { get; internal set; } + private PermissionOverwrite[] _permissionOverwrites; + public IEnumerable PermissionOverwrites => _permissionOverwrites; internal Channel(DiscordClient client, string id, string serverId, string recipientId) { @@ -96,7 +100,7 @@ namespace Discord if (model.PermissionOverwrites != null) { - PermissionOverwrites = model.PermissionOverwrites.Select(x => new PermissionOverwrite + _permissionOverwrites = model.PermissionOverwrites.Select(x => new PermissionOverwrite { Type = x.Type, Id = x.Id, @@ -105,7 +109,7 @@ namespace Discord }).ToArray(); } else - PermissionOverwrites = null; + _permissionOverwrites = null; } public override string ToString() => Name; diff --git a/src/Discord.Net/Models/Member.cs b/src/Discord.Net/Models/Member.cs index a030326b3..863113b52 100644 --- a/src/Discord.Net/Models/Member.cs +++ b/src/Discord.Net/Models/Member.cs @@ -191,8 +191,12 @@ namespace Discord } } //TODO: Add GetServerPermissions - public PackedChannelPermissions GetPermissions(string channelId) + public PackedChannelPermissions GetPermissions(Channel channel) + => GetPermissions(channel?.Id); + public PackedChannelPermissions GetPermissions(string channelId) { + if (channelId == null) throw new ArgumentNullException(nameof(channelId)); + PackedChannelPermissions perms; if (_permissions.TryGetValue(channelId, out perms)) return perms;