Attempting to retrieve last N number of messages with Channel.GetMessagesAsync retrieves only from cache and doesn't download the missing rest.
[Command("getmessages")]
public async Task GetMessages()
{
var channel = await Context.Channel.GetMessagesAsync(50, CacheMode.AllowDownload).FirstOrDefault();
var api = await Context.Client.ApiClient.GetChannelMessagesAsync(
Context.Channel.Id,
new API.Rest.GetChannelMessagesParams { Limit = 50 });
await ReplyAsync($"Channel has {channel.Count} messages\nApi has {api.Count} messages");
}
will output
Channel has 1 messages
Api has 50 messages
.FirstOrDefault() <----
Not to mention there are other issues with that. You want to call .Flatten() at the end
Most helpful comment
.FirstOrDefault()<----