Skip to content

[Bug]: GetMessagesAsync with Direction.After not working as expected #2744

@josago97

Description

@josago97

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

I am trying to get all messages from another. However, when I call the GetMessagesAsync method with Direction.After it only returns one message, the most recent message. It doesn't matter what message id parameter I put, it always returns the most recent message. Direction. Direction.Before works correctly. This problem only occurs when getting the messages inside a method called by command, otherwise if it works correctly. It seems, from what I've seen on the Discord forum, that this problem has been going on for 3 years. There is a related issue (#1803), but it was closed with no apparent solution.

Version

3.11.0

Working Version

No response

Logs

-none-

Sample

[Command("a", RunMode = RunMode.Async)]
public async Task Test()
{
        SocketTextChannel channel = Context.Channel as SocketTextChannel;
        IEnumerable<IMessage> messages = await channel.GetMessagesAsync(1138076161021333664, Direction.After).FlattenAsync();
        Console.WriteLine(messages.Count());
}

Packages

.NET 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions