Browse Source

Added Memberships and Servers IEnumerables to User. Added doc to User.PrivateChannel.

tags/docs-0.9
RogueException 9 years ago
parent
commit
3eb72bf826
2 changed files with 15 additions and 6 deletions
  1. +5
    -5
      src/Discord.Net/DiscordClient.Cache.cs
  2. +10
    -1
      src/Discord.Net/Models/User.cs

+ 5
- 5
src/Discord.Net/DiscordClient.Cache.cs View File

@@ -12,27 +12,27 @@ namespace Discord
/// <summary> Returns a collection of all users the client can see across all servers. </summary> /// <summary> Returns a collection of all users the client can see across all servers. </summary>
/// <remarks> This collection does not guarantee any ordering. </remarks> /// <remarks> This collection does not guarantee any ordering. </remarks>
public IEnumerable<User> Users => _users; public IEnumerable<User> Users => _users;
private AsyncCache<User, API.Models.UserReference> _users;
internal AsyncCache<User, API.Models.UserReference> _users;


/// <summary> Returns a collection of all servers the client is a member of. </summary> /// <summary> Returns a collection of all servers the client is a member of. </summary>
/// <remarks> This collection does not guarantee any ordering. </remarks> /// <remarks> This collection does not guarantee any ordering. </remarks>
public IEnumerable<Server> Servers => _servers; public IEnumerable<Server> Servers => _servers;
private AsyncCache<Server, API.Models.ServerReference> _servers;
internal AsyncCache<Server, API.Models.ServerReference> _servers;


/// <summary> Returns a collection of all channels the client can see across all servers. </summary> /// <summary> Returns a collection of all channels the client can see across all servers. </summary>
/// <remarks> This collection does not guarantee any ordering. </remarks> /// <remarks> This collection does not guarantee any ordering. </remarks>
public IEnumerable<Channel> Channels => _channels; public IEnumerable<Channel> Channels => _channels;
private AsyncCache<Channel, API.Models.ChannelReference> _channels;
internal AsyncCache<Channel, API.Models.ChannelReference> _channels;


/// <summary> Returns a collection of all messages the client has in cache. </summary> /// <summary> Returns a collection of all messages the client has in cache. </summary>
/// <remarks> This collection does not guarantee any ordering. </remarks> /// <remarks> This collection does not guarantee any ordering. </remarks>
public IEnumerable<Message> Messages => _messages; public IEnumerable<Message> Messages => _messages;
private AsyncCache<Message, API.Models.MessageReference> _messages;
internal AsyncCache<Message, API.Models.MessageReference> _messages;


/// <summary> Returns a collection of all roles the client can see across all servers. </summary> /// <summary> Returns a collection of all roles the client can see across all servers. </summary>
/// <remarks> This collection does not guarantee any ordering. </remarks> /// <remarks> This collection does not guarantee any ordering. </remarks>
public IEnumerable<Role> Roles => _roles; public IEnumerable<Role> Roles => _roles;
private AsyncCache<Role, API.Models.Role> _roles;
internal AsyncCache<Role, API.Models.Role> _roles;


private void CreateCaches() private void CreateCaches()
{ {


+ 10
- 1
src/Discord.Net/Models/User.cs View File

@@ -1,6 +1,8 @@
using Discord.API; using Discord.API;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Linq;


namespace Discord namespace Discord
{ {
@@ -28,10 +30,17 @@ namespace Discord
/// <remarks> This field is only ever populated for the current logged in user. </remarks> /// <remarks> This field is only ever populated for the current logged in user. </remarks>
public bool IsVerified { get; internal set; } public bool IsVerified { get; internal set; }


/// <summary> Returns the Id of the private messaging channel with this user, if one exists. </summary>
public string PrivateChannelId { get; set; } public string PrivateChannelId { get; set; }
/// <summary> Returns the private messaging channel with this user, if one exists. </summary>
public Channel PrivateChannel => _client.GetChannel(PrivateChannelId); public Channel PrivateChannel => _client.GetChannel(PrivateChannelId);


//TODO: Add voice
/// <summary> Returns a collection of all server-specific data for every server this user is a member of. </summary>
public IEnumerable<Member> Memberships => _client._servers.Select(x => x._members[Id]).Where(x => x != null);
/// <summary> Returns a collection of all servers this user is a member of. </summary>
public IEnumerable<Server> Servers => _client._servers.Where(x => x._members[Id] != null);

//TODO: Add voice triggering lastactivity
/// <summary> Returns the time this user last sent a message. </summary> /// <summary> Returns the time this user last sent a message. </summary>
/// <remarks> Is not currently affected by voice activity </remarks> /// <remarks> Is not currently affected by voice activity </remarks>
public DateTime LastActivity { get; private set; } public DateTime LastActivity { get; private set; }


Loading…
Cancel
Save