| @@ -132,7 +132,7 @@ namespace Discord | |||||
| Channel channel = null; | Channel channel = null; | ||||
| if (user != null) | if (user != null) | ||||
| channel = user.GlobalUser.PrivateChannel; | |||||
| channel = user.Global.PrivateChannel; | |||||
| if (channel == null) | if (channel == null) | ||||
| { | { | ||||
| var response = await _api.CreatePMChannel(_userId.Value, user.Id).ConfigureAwait(false); | var response = await _api.CreatePMChannel(_userId.Value, user.Id).ConfigureAwait(false); | ||||
| @@ -134,7 +134,7 @@ namespace Discord | |||||
| private User _privateUser; | private User _privateUser; | ||||
| /// <summary> Returns information about the currently logged-in account. </summary> | /// <summary> Returns information about the currently logged-in account. </summary> | ||||
| public GlobalUser CurrentUser => _privateUser.GlobalUser; | |||||
| public GlobalUser CurrentUser => _privateUser.Global; | |||||
| /// <summary> Returns a collection of all unique users this client can currently see. </summary> | /// <summary> Returns a collection of all unique users this client can currently see. </summary> | ||||
| public IEnumerable<GlobalUser> AllUsers => _globalUsers; | public IEnumerable<GlobalUser> AllUsers => _globalUsers; | ||||
| @@ -275,7 +275,7 @@ namespace Discord | |||||
| CheckReady(); | CheckReady(); | ||||
| return _api.EditUser(currentPassword: currentPassword, | return _api.EditUser(currentPassword: currentPassword, | ||||
| username: username ?? _privateUser?.Name, email: email ?? _privateUser?.GlobalUser.Email, password: password, | |||||
| username: username ?? _privateUser?.Name, email: email ?? _privateUser?.Global.Email, password: password, | |||||
| avatarType: avatarType, avatar: avatar); | avatarType: avatarType, avatar: avatar); | ||||
| } | } | ||||
| @@ -314,7 +314,7 @@ namespace Discord | |||||
| var data = e.Payload.ToObject<ReadyEvent>(_serializer); | var data = e.Payload.ToObject<ReadyEvent>(_serializer); | ||||
| _privateUser = _users.GetOrAdd(data.User.Id, null); | _privateUser = _users.GetOrAdd(data.User.Id, null); | ||||
| _privateUser.Update(data.User); | _privateUser.Update(data.User); | ||||
| _privateUser.GlobalUser.Update(data.User); | |||||
| _privateUser.Global.Update(data.User); | |||||
| foreach (var model in data.Guilds) | foreach (var model in data.Guilds) | ||||
| { | { | ||||
| if (model.Unavailable != true) | if (model.Unavailable != true) | ||||
| @@ -50,13 +50,18 @@ namespace Discord | |||||
| /// <summary> Returns the server containing this channel. </summary> | /// <summary> Returns the server containing this channel. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Server Server => _server.Value; | public Server Server => _server.Value; | ||||
| [JsonProperty] | |||||
| private long? ServerId { get { return _server.Id; } set { _server.Id = value; } } | |||||
| private readonly Reference<Server> _server; | private readonly Reference<Server> _server; | ||||
| /// For private chats, returns the target user, otherwise null. | /// For private chats, returns the target user, otherwise null. | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public User Recipient => _recipient.Value; | public User Recipient => _recipient.Value; | ||||
| private readonly Reference<User> _recipient; | |||||
| [JsonProperty] | |||||
| private long? RecipientId { get { return _recipient.Id; } set { _recipient.Id = value; } } | |||||
| private readonly Reference<User> _recipient; | |||||
| //Collections | |||||
| /// <summary> Returns a collection of all users with read access to this channel. </summary> | /// <summary> Returns a collection of all users with read access to this channel. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<User> Members | public IEnumerable<User> Members | ||||
| @@ -66,20 +71,23 @@ namespace Discord | |||||
| if (Type == ChannelType.Text) | if (Type == ChannelType.Text) | ||||
| return _members.Values.Where(x => x.Permissions.ReadMessages == true).Select(x => x.User); | return _members.Values.Where(x => x.Permissions.ReadMessages == true).Select(x => x.User); | ||||
| else if (Type == ChannelType.Voice) | else if (Type == ChannelType.Voice) | ||||
| return Server.Members.Where(x => x.VoiceChannel == this); | |||||
| return _members.Values.Select(x => x.User).Where(x => x.VoiceChannel == this); | |||||
| else | else | ||||
| return Enumerable.Empty<User>(); | return Enumerable.Empty<User>(); | ||||
| } | } | ||||
| } | } | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MemberIds => Members.Select(x => x.Id); | |||||
| private ConcurrentDictionary<long, ChannelMember> _members; | private ConcurrentDictionary<long, ChannelMember> _members; | ||||
| /// <summary> Returns a collection of all messages the client has seen posted in this channel. This collection does not guarantee any ordering. </summary> | /// <summary> Returns a collection of all messages the client has seen posted in this channel. This collection does not guarantee any ordering. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<Message> Messages => _messages?.Values ?? Enumerable.Empty<Message>(); | public IEnumerable<Message> Messages => _messages?.Values ?? Enumerable.Empty<Message>(); | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MessageIds => Messages.Select(x => x.Id); | |||||
| private readonly ConcurrentDictionary<long, Message> _messages; | private readonly ConcurrentDictionary<long, Message> _messages; | ||||
| /// <summary> Returns a collection of all custom permissions used for this channel. </summary> | /// <summary> Returns a collection of all custom permissions used for this channel. </summary> | ||||
| private static readonly PermissionOverwrite[] _initialPermissionsOverwrites = new PermissionOverwrite[0]; | |||||
| private PermissionOverwrite[] _permissionOverwrites; | private PermissionOverwrite[] _permissionOverwrites; | ||||
| public IEnumerable<PermissionOverwrite> PermissionOverwrites { get { return _permissionOverwrites; } internal set { _permissionOverwrites = value.ToArray(); } } | public IEnumerable<PermissionOverwrite> PermissionOverwrites { get { return _permissionOverwrites; } internal set { _permissionOverwrites = value.ToArray(); } } | ||||
| @@ -96,14 +104,14 @@ namespace Discord | |||||
| { | { | ||||
| Name = "@" + x.Name; | Name = "@" + x.Name; | ||||
| if (_server.Id == null) | if (_server.Id == null) | ||||
| x.GlobalUser.PrivateChannel = this; | |||||
| x.Global.PrivateChannel = this; | |||||
| }, | }, | ||||
| x => | x => | ||||
| { | { | ||||
| if (_server.Id == null) | if (_server.Id == null) | ||||
| x.GlobalUser.PrivateChannel = null; | |||||
| x.Global.PrivateChannel = null; | |||||
| }); | }); | ||||
| _permissionOverwrites = _initialPermissionsOverwrites; | |||||
| _permissionOverwrites = new PermissionOverwrite[0]; | |||||
| _members = new ConcurrentDictionary<long, ChannelMember>(); | _members = new ConcurrentDictionary<long, ChannelMember>(); | ||||
| if (recipientId != null) | if (recipientId != null) | ||||
| @@ -8,7 +8,6 @@ namespace Discord | |||||
| { | { | ||||
| public sealed class GlobalUser : CachedObject<long> | public sealed class GlobalUser : CachedObject<long> | ||||
| { | { | ||||
| private readonly ConcurrentDictionary<long, User> _users; | |||||
| /// <summary> Returns the email for this user. Note: this field is only ever populated for the current logged in user. </summary> | /// <summary> Returns the email for this user. Note: this field is only ever populated for the current logged in user. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| @@ -19,7 +18,7 @@ namespace Discord | |||||
| /// <summary> Returns the private messaging channel with this user, if one exists. </summary> | /// <summary> Returns the private messaging channel with this user, if one exists. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| internal Channel PrivateChannel | |||||
| public Channel PrivateChannel | |||||
| { | { | ||||
| get { return _privateChannel; } | get { return _privateChannel; } | ||||
| set | set | ||||
| @@ -29,11 +28,16 @@ namespace Discord | |||||
| CheckUser(); | CheckUser(); | ||||
| } | } | ||||
| } | } | ||||
| private Channel _privateChannel; | |||||
| [JsonProperty] | |||||
| private long? PrivateChannelId => _privateChannel?.Id; | |||||
| private Channel _privateChannel; | |||||
| /// <summary> Returns a collection of all server-specific data for every server this user is a member of. </summary> | /// <summary> Returns a collection of all server-specific data for every server this user is a member of. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<User> Memberships => _users.Select(x => x.Value); | public IEnumerable<User> Memberships => _users.Select(x => x.Value); | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> ServerIds => _users.Select(x => x.Key); | |||||
| private readonly ConcurrentDictionary<long, User> _users; | |||||
| internal GlobalUser(DiscordClient client, long id) | internal GlobalUser(DiscordClient client, long id) | ||||
| : base(client, id) | : base(client, id) | ||||
| @@ -94,6 +94,8 @@ namespace Discord | |||||
| /// <summary> Returns true if the logged-in user was mentioned. </summary> | /// <summary> Returns true if the logged-in user was mentioned. </summary> | ||||
| /// <remarks> This is not set to true if the user was mentioned with @everyone (see IsMentioningEverone). </remarks> | /// <remarks> This is not set to true if the user was mentioned with @everyone (see IsMentioningEverone). </remarks> | ||||
| public bool IsMentioningMe { get; private set; } | public bool IsMentioningMe { get; private set; } | ||||
| /// <summary> Returns true if the current user created this message. </summary> | |||||
| public bool IsAuthor => _client.CurrentUserId == _user.Id; | |||||
| /// <summary> Returns true if the message was sent as text-to-speech by someone with permissions to do so. </summary> | /// <summary> Returns true if the message was sent as text-to-speech by someone with permissions to do so. </summary> | ||||
| public bool IsTTS { get; private set; } | public bool IsTTS { get; private set; } | ||||
| /// <summary> Returns true if the message is still in the outgoing message queue. </summary> | /// <summary> Returns true if the message is still in the outgoing message queue. </summary> | ||||
| @@ -118,28 +120,49 @@ namespace Discord | |||||
| /// <summary> Returns a collection of all users mentioned in this message. </summary> | /// <summary> Returns a collection of all users mentioned in this message. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<User> MentionedUsers { get; internal set; } | public IEnumerable<User> MentionedUsers { get; internal set; } | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MentionedUserIds | |||||
| { | |||||
| get { return MentionedUsers.Select(x => x.Id); } | |||||
| set { MentionedUsers = value.Select(x => _client.GetUser(Server, x)).Where(x => x != null); } | |||||
| } | |||||
| /// <summary> Returns a collection of all channels mentioned in this message. </summary> | /// <summary> Returns a collection of all channels mentioned in this message. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<Channel> MentionedChannels { get; internal set; } | public IEnumerable<Channel> MentionedChannels { get; internal set; } | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MentionedChannelIds | |||||
| { | |||||
| get { return MentionedChannels.Select(x => x.Id); } | |||||
| set { MentionedChannels = value.Select(x => _client.GetChannel(x)).Where(x => x != null); } | |||||
| } | |||||
| /// <summary> Returns a collection of all roles mentioned in this message. </summary> | /// <summary> Returns a collection of all roles mentioned in this message. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<Role> MentionedRoles { get; internal set; } | public IEnumerable<Role> MentionedRoles { get; internal set; } | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MentionedRoleIds | |||||
| { | |||||
| get { return MentionedRoles.Select(x => x.Id); } | |||||
| set { MentionedRoles = value.Select(x => _client.GetRole(x)).Where(x => x != null); } | |||||
| } | |||||
| /// <summary> Returns the server containing the channel this message was sent to. </summary> | /// <summary> Returns the server containing the channel this message was sent to. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Server Server => _channel.Value.Server; | public Server Server => _channel.Value.Server; | ||||
| /// <summary> Returns the channel this message was sent to. </summary> | /// <summary> Returns the channel this message was sent to. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Channel Channel => _channel.Value; | public Channel Channel => _channel.Value; | ||||
| [JsonProperty] | |||||
| private long? ChannelId { get { return _channel.Id; } set { _channel.Id = value; } } | |||||
| private readonly Reference<Channel> _channel; | private readonly Reference<Channel> _channel; | ||||
| /// <summary> Returns true if the current user created this message. </summary> | |||||
| public bool IsAuthor => _client.CurrentUserId == _user.Id; | |||||
| /// <summary> Returns the author of this message. </summary> | /// <summary> Returns the author of this message. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public User User => _user.Value; | public User User => _user.Value; | ||||
| [JsonProperty] | |||||
| private long? UserId { get { return _user.Id; } set { _user.Id = value; } } | |||||
| private readonly Reference<User> _user; | private readonly Reference<User> _user; | ||||
| internal Message(DiscordClient client, long id, long channelId, long userId) | internal Message(DiscordClient client, long id, long channelId, long userId) | ||||
| @@ -24,13 +24,18 @@ namespace Discord | |||||
| /// <summary> Returns the server this role is a member of. </summary> | /// <summary> Returns the server this role is a member of. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Server Server => _server.Value; | public Server Server => _server.Value; | ||||
| [JsonProperty] | |||||
| private long? ServerId { get { return _server.Id; } set { _server.Id = value; } } | |||||
| private readonly Reference<Server> _server; | private readonly Reference<Server> _server; | ||||
| /// <summary> Returns true if this is the role representing all users in a server. </summary> | /// <summary> Returns true if this is the role representing all users in a server. </summary> | ||||
| public bool IsEveryone => _server.Id == null || Id == _server.Id; | public bool IsEveryone => _server.Id == null || Id == _server.Id; | ||||
| /// <summary> Returns a list of all members in this role. </summary> | /// <summary> Returns a list of all members in this role. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<User> Members => _server.Id != null ? (IsEveryone ? Server.Members : Server.Members.Where(x => x.HasRole(this))) : new User[0]; | public IEnumerable<User> Members => _server.Id != null ? (IsEveryone ? Server.Members : Server.Members.Where(x => x.HasRole(this))) : new User[0]; | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MemberIds => Members.Select(x => x.Id); | |||||
| //TODO: Add local members cache | //TODO: Add local members cache | ||||
| internal Role(DiscordClient client, long id, long serverId) | internal Role(DiscordClient client, long id, long serverId) | ||||
| @@ -35,15 +35,20 @@ namespace Discord | |||||
| public string Region { get; private set; } | public string Region { get; private set; } | ||||
| /// <summary> Returns true if the current user created this server. </summary> | /// <summary> Returns true if the current user created this server. </summary> | ||||
| public bool IsOwner => _client.CurrentUserId == _ownerId; | |||||
| public bool IsOwner => _client.CurrentUserId == _owner.Id; | |||||
| /// <summary> Returns the user that first created this server. </summary> | /// <summary> Returns the user that first created this server. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public User Owner { get; private set; } | |||||
| private long _ownerId; | |||||
| public User Owner => _owner.Value; | |||||
| [JsonProperty] | |||||
| private long? OwnerId => _owner.Id; | |||||
| private Reference<User> _owner; | |||||
| /// <summary> Returns the AFK voice channel for this server (see AFKTimeout). </summary> | /// <summary> Returns the AFK voice channel for this server (see AFKTimeout). </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Channel AFKChannel => _afkChannel.Value; | public Channel AFKChannel => _afkChannel.Value; | ||||
| [JsonProperty] | |||||
| private long? AFKChannelId => _afkChannel.Id; | |||||
| private Reference<Channel> _afkChannel; | private Reference<Channel> _afkChannel; | ||||
| /// <summary> Returns the default channel for this server. </summary> | /// <summary> Returns the default channel for this server. </summary> | ||||
| @@ -51,8 +56,7 @@ namespace Discord | |||||
| public Channel DefaultChannel { get; private set; } | public Channel DefaultChannel { get; private set; } | ||||
| /// <summary> Returns a collection of the ids of all users banned on this server. </summary> | /// <summary> Returns a collection of the ids of all users banned on this server. </summary> | ||||
| [JsonIgnore] | |||||
| public IEnumerable<long> Bans => _bans.Select(x => x.Key); | |||||
| public IEnumerable<long> BannedUsers => _bans.Select(x => x.Key); | |||||
| private ConcurrentDictionary<long, bool> _bans; | private ConcurrentDictionary<long, bool> _bans; | ||||
| /// <summary> Returns a collection of all channels within this server. </summary> | /// <summary> Returns a collection of all channels within this server. </summary> | ||||
| @@ -64,11 +68,15 @@ namespace Discord | |||||
| /// <summary> Returns a collection of all voice channels within this server. </summary> | /// <summary> Returns a collection of all voice channels within this server. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<Channel> VoiceChannels => _channels.Select(x => x.Value).Where(x => x.Type == ChannelType.Voice); | public IEnumerable<Channel> VoiceChannels => _channels.Select(x => x.Value).Where(x => x.Type == ChannelType.Voice); | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> ChannelIds => Channels.Select(x => x.Id); | |||||
| private ConcurrentDictionary<long, Channel> _channels; | private ConcurrentDictionary<long, Channel> _channels; | ||||
| /// <summary> Returns a collection of all users within this server with their server-specific data. </summary> | /// <summary> Returns a collection of all users within this server with their server-specific data. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<User> Members => _members.Select(x => x.Value.User); | public IEnumerable<User> Members => _members.Select(x => x.Value.User); | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> MemberIds => Members.Select(x => x.Id); | |||||
| private ConcurrentDictionary<long, ServerMember> _members; | private ConcurrentDictionary<long, ServerMember> _members; | ||||
| /// <summary> Return the the role representing all users in a server. </summary> | /// <summary> Return the the role representing all users in a server. </summary> | ||||
| @@ -77,11 +85,14 @@ namespace Discord | |||||
| /// <summary> Returns a collection of all roles within this server. </summary> | /// <summary> Returns a collection of all roles within this server. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<Role> Roles => _roles.Select(x => x.Value); | public IEnumerable<Role> Roles => _roles.Select(x => x.Value); | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> RoleIds => Roles.Select(x => x.Id); | |||||
| private ConcurrentDictionary<long, Role> _roles; | private ConcurrentDictionary<long, Role> _roles; | ||||
| internal Server(DiscordClient client, long id) | internal Server(DiscordClient client, long id) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| _owner = new Reference<User>(x => _client.Users[x, Id]); | |||||
| _afkChannel = new Reference<Channel>(x => _client.Channels[x]); | _afkChannel = new Reference<Channel>(x => _client.Channels[x]); | ||||
| //Global Cache | //Global Cache | ||||
| @@ -138,11 +149,8 @@ namespace Discord | |||||
| if (model.AFKChannelId != null) | if (model.AFKChannelId != null) | ||||
| if (model.JoinedAt != null) | if (model.JoinedAt != null) | ||||
| JoinedAt = model.JoinedAt.Value; | JoinedAt = model.JoinedAt.Value; | ||||
| if (model.OwnerId != null && _ownerId != model.OwnerId) | |||||
| { | |||||
| _ownerId = model.OwnerId.Value; | |||||
| Owner = _client.Users[_ownerId, Id]; | |||||
| } | |||||
| if (model.OwnerId != null) | |||||
| _owner.Id = model.OwnerId.Value; | |||||
| if (model.Region != null) | if (model.Region != null) | ||||
| Region = model.Region; | Region = model.Region; | ||||
| @@ -216,9 +224,6 @@ namespace Discord | |||||
| { | { | ||||
| if (_members.TryAdd(user.Id, new ServerMember(user))) | if (_members.TryAdd(user.Id, new ServerMember(user))) | ||||
| { | { | ||||
| if (user.Id == _ownerId) | |||||
| Owner = user; | |||||
| foreach (var channel in TextChannels) | foreach (var channel in TextChannels) | ||||
| channel.AddMember(user); | channel.AddMember(user); | ||||
| } | } | ||||
| @@ -228,9 +233,6 @@ namespace Discord | |||||
| ServerMember ignored; | ServerMember ignored; | ||||
| if (_members.TryRemove(user.Id, out ignored)) | if (_members.TryRemove(user.Id, out ignored)) | ||||
| { | { | ||||
| if (user.Id == _ownerId) | |||||
| Owner = null; | |||||
| foreach (var channel in Channels) | foreach (var channel in Channels) | ||||
| channel.RemoveMember(user); | channel.RemoveMember(user); | ||||
| } | } | ||||
| @@ -1,7 +1,6 @@ | |||||
| using Discord.API; | using Discord.API; | ||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using System; | using System; | ||||
| using System.Collections.Concurrent; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | using System.Linq; | ||||
| @@ -60,25 +59,29 @@ namespace Discord | |||||
| public DateTime? LastOnlineAt => Status != UserStatus.Offline ? DateTime.UtcNow : _lastOnline; | public DateTime? LastOnlineAt => Status != UserStatus.Offline ? DateTime.UtcNow : _lastOnline; | ||||
| private DateTime? _lastOnline; | private DateTime? _lastOnline; | ||||
| /// <summary> Returns the private messaging channel with this user, if one exists. </summary> | |||||
| //References | |||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Channel PrivateChannel => GlobalUser.PrivateChannel; | |||||
| [JsonIgnore] | |||||
| internal GlobalUser GlobalUser => _globalUser.Value; | |||||
| public GlobalUser Global => _globalUser.Value; | |||||
| private readonly Reference<GlobalUser> _globalUser; | private readonly Reference<GlobalUser> _globalUser; | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Server Server => _server.Value; | public Server Server => _server.Value; | ||||
| private readonly Reference<Server> _server; | private readonly Reference<Server> _server; | ||||
| [JsonProperty] | |||||
| private long? ServerId { get { return _server.Id; } set { _server.Id = value; } } | |||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public Channel VoiceChannel => _voiceChannel.Value; | public Channel VoiceChannel => _voiceChannel.Value; | ||||
| private Reference<Channel> _voiceChannel; | private Reference<Channel> _voiceChannel; | ||||
| [JsonProperty] | |||||
| private long? VoiceChannelId { get { return _voiceChannel.Id; } set { _voiceChannel.Id = value; } } | |||||
| //Collections | |||||
| [JsonIgnore] | [JsonIgnore] | ||||
| public IEnumerable<Role> Roles => _roles.Select(x => x.Value); | public IEnumerable<Role> Roles => _roles.Select(x => x.Value); | ||||
| private Dictionary<long, Role> _roles; | private Dictionary<long, Role> _roles; | ||||
| [JsonProperty] | |||||
| private IEnumerable<long> RoleIds => _roles.Select(x => x.Key); | |||||
| /// <summary> Returns a collection of all messages this user has sent on this server that are still in cache. </summary> | /// <summary> Returns a collection of all messages this user has sent on this server that are still in cache. </summary> | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| @@ -89,7 +92,7 @@ namespace Discord | |||||
| if (_server.Id != null) | if (_server.Id != null) | ||||
| return Server.Channels.SelectMany(x => x.Messages.Where(y => y.User.Id == Id)); | return Server.Channels.SelectMany(x => x.Messages.Where(y => y.User.Id == Id)); | ||||
| else | else | ||||
| return GlobalUser.PrivateChannel.Messages.Where(x => x.User.Id == Id); | |||||
| return Global.PrivateChannel.Messages.Where(x => x.User.Id == Id); | |||||
| } | } | ||||
| } | } | ||||
| @@ -106,7 +109,7 @@ namespace Discord | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| var privateChannel = PrivateChannel; | |||||
| var privateChannel = Global.PrivateChannel; | |||||
| if (privateChannel != null) | if (privateChannel != null) | ||||
| return new Channel[] { privateChannel }; | return new Channel[] { privateChannel }; | ||||
| else | else | ||||