Table of Contents

Method DeleteMessagesAsync

Namespace
DSharpPlus.Entities
Assembly
DSharpPlus.dll

DeleteMessagesAsync(IReadOnlyList<DiscordMessage>, string?)

Deletes multiple messages if they are less than 14 days old. If they are older, none of the messages will be deleted and you will receive a ArgumentException error.

public Task<int> DeleteMessagesAsync(IReadOnlyList<DiscordMessage> messages, string? reason = null)

Parameters

messages IReadOnlyList<DiscordMessage>

A collection of messages to delete.

reason string

Reason for audit logs.

Returns

Task<int>

The number of deleted messages

Remarks

One api call per 100 messages

DeleteMessagesAsync(IAsyncEnumerable<DiscordMessage>, string?)

Deletes multiple messages if they are less than 14 days old. Does one api request per 100

public Task<int> DeleteMessagesAsync(IAsyncEnumerable<DiscordMessage> messages, string? reason = null)

Parameters

messages IAsyncEnumerable<DiscordMessage>

A collection of messages to delete.

reason string

Reason for audit logs.

Returns

Task<int>

The number of deleted messages

Remarks

One api call per 100 messages

Exceptions

BulkDeleteFailedException

Exception which contains the exception which was thrown and the count of messages which were deleted successfully