From 3eb72bf8263eb6c252957b8b3cafcff863864be3 Mon Sep 17 00:00:00 2001 From: RogueException Date: Mon, 7 Sep 2015 23:24:20 -0300 Subject: [PATCH] Added Memberships and Servers IEnumerables to User. Added doc to User.PrivateChannel. --- src/Discord.Net/DiscordClient.Cache.cs | 10 +++++----- src/Discord.Net/Models/User.cs | 11 ++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Discord.Net/DiscordClient.Cache.cs b/src/Discord.Net/DiscordClient.Cache.cs index ef2012ab8..5dea7a416 100644 --- a/src/Discord.Net/DiscordClient.Cache.cs +++ b/src/Discord.Net/DiscordClient.Cache.cs @@ -12,27 +12,27 @@ namespace Discord /// Returns a collection of all users the client can see across all servers. /// This collection does not guarantee any ordering. public IEnumerable Users => _users; - private AsyncCache _users; + internal AsyncCache _users; /// Returns a collection of all servers the client is a member of. /// This collection does not guarantee any ordering. public IEnumerable Servers => _servers; - private AsyncCache _servers; + internal AsyncCache _servers; /// Returns a collection of all channels the client can see across all servers. /// This collection does not guarantee any ordering. public IEnumerable Channels => _channels; - private AsyncCache _channels; + internal AsyncCache _channels; /// Returns a collection of all messages the client has in cache. /// This collection does not guarantee any ordering. public IEnumerable Messages => _messages; - private AsyncCache _messages; + internal AsyncCache _messages; /// Returns a collection of all roles the client can see across all servers. /// This collection does not guarantee any ordering. public IEnumerable Roles => _roles; - private AsyncCache _roles; + internal AsyncCache _roles; private void CreateCaches() { diff --git a/src/Discord.Net/Models/User.cs b/src/Discord.Net/Models/User.cs index 19575d014..ad55a300a 100644 --- a/src/Discord.Net/Models/User.cs +++ b/src/Discord.Net/Models/User.cs @@ -1,6 +1,8 @@ using Discord.API; using Newtonsoft.Json; using System; +using System.Collections.Generic; +using System.Linq; namespace Discord { @@ -28,10 +30,17 @@ namespace Discord /// This field is only ever populated for the current logged in user. public bool IsVerified { get; internal set; } + /// Returns the Id of the private messaging channel with this user, if one exists. public string PrivateChannelId { get; set; } + /// Returns the private messaging channel with this user, if one exists. public Channel PrivateChannel => _client.GetChannel(PrivateChannelId); - //TODO: Add voice + /// Returns a collection of all server-specific data for every server this user is a member of. + public IEnumerable Memberships => _client._servers.Select(x => x._members[Id]).Where(x => x != null); + /// Returns a collection of all servers this user is a member of. + public IEnumerable Servers => _client._servers.Where(x => x._members[Id] != null); + + //TODO: Add voice triggering lastactivity /// Returns the time this user last sent a message. /// Is not currently affected by voice activity public DateTime LastActivity { get; private set; }