Fixed error when calling GetMessagesAsync with no cached messages

This commit is contained in:
RogueException
2016-10-12 15:32:22 -03:00
parent 2d3e2c46ae
commit 82ee6c5aaa

View File

@@ -34,9 +34,10 @@ namespace Discord.WebSocket
limit -= cachedMessages.Count;
if (mode == CacheMode.CacheOnly || limit <= 0)
return result;
//Download remaining messages
var downloadedMessages = ChannelHelper.GetMessagesAsync(channel, discord, cachedMessages.Min(x => x.Id), dir, limit, guild, options);
ulong? minId = cachedMessages.Count > 0 ? cachedMessages.Min(x => x.Id) : (ulong?)null;
var downloadedMessages = ChannelHelper.GetMessagesAsync(channel, discord, minId, dir, limit, guild, options);
return result.Concat(downloadedMessages);
}
else