public static async Task <IReadOnlyCollection <DiscordMessage> > GetMessagesBeforeAsync(this DiscordChannel channel, ulong beforeMessageId, int limit = 100, DateTime?timeLimit = null) { if (timeLimit > DateTime.UtcNow) { throw new ArgumentException("Time limit can't be set in the future", nameof(timeLimit)); } var afterTime = timeLimit ?? DateTime.UtcNow.AddSeconds(-30); var messages = await channel.GetMessagesBeforeCachedAsync(beforeMessageId, limit).ConfigureAwait(false); return(messages.TakeWhile(m => m.CreationTimestamp > afterTime).ToList().AsReadOnly()); }