From b8e201d65251f3da4f4147de00e7969e70148dd7 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 25 Oct 2015 05:13:00 -0300 Subject: [PATCH] Fixed and improved performance of User.Messages --- src/Discord.Net/Models/User.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net/Models/User.cs b/src/Discord.Net/Models/User.cs index 3fdaada94..935fd4fdc 100644 --- a/src/Discord.Net/Models/User.cs +++ b/src/Discord.Net/Models/User.cs @@ -69,7 +69,16 @@ namespace Discord /// Returns a collection of all messages this user has sent on this server that are still in cache. [JsonIgnore] - public IEnumerable Messages => _client.Messages.Where(x => x.User.Id == Id && x.Server.Id == _server.Id); + public IEnumerable Messages + { + get + { + if (_server.Id != null) + return Server.Channels.SelectMany(x => x.Messages.Where(y => y.User.Id == Id)); + else + return GlobalUser.PrivateChannel.Messages.Where(x => x.User.Id == Id); + } + } /// Returns a collection of all channels this user is a member of. [JsonIgnore]