Table of Contents

Method GetMessagesAsync

Namespace
DSharpPlus.Entities
Assembly
DSharpPlus.dll

GetMessagesAsync(int, CancellationToken)

Returns a list of messages from the last message in the channel. This will execute one API request per 100 messages.

The amount of messages to fetch.Cancels the enumeration before doing the next api request
public IAsyncEnumerable<DiscordMessage> GetMessagesAsync(int limit = 100, CancellationToken cancellationToken = default)

Parameters

limit int
cancellationToken CancellationToken

Returns

IAsyncEnumerable<DiscordMessage>

Exceptions

UnauthorizedException

Thrown when the client does not have the AccessChannels permission.

NotFoundException

Thrown when the channel does not exist.

BadRequestException

Thrown when an invalid parameter was provided.

ServerErrorException

Thrown when Discord is unable to process the request.