Discord.net: Channel.GetMessagesAsync is not downloading messages

Created on 16 Dec 2016  路  2Comments  路  Source: discord-net/Discord.Net

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

Most helpful comment

.FirstOrDefault() <----

All 2 comments

.FirstOrDefault() <----

Not to mention there are other issues with that. You want to call .Flatten() at the end

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nolij picture Nolij  路  5Comments

foxbot picture foxbot  路  4Comments

MinisBett picture MinisBett  路  3Comments

Foxite picture Foxite  路  4Comments

GHosaPhat picture GHosaPhat  路  7Comments