Table of Contents

Method BanMemberAsync

Namespace
DSharpPlus.Entities
Assembly
DSharpPlus.dll

BanMemberAsync(DiscordUser, TimeSpan, string?)

Bans a specified member from this guild.

public Task BanMemberAsync(DiscordUser member, TimeSpan messageDeleteDuration = default, string? reason = null)

Parameters

member DiscordUser

Member to ban.

messageDeleteDuration TimeSpan

The duration in which discord should delete messages from the banned user.

reason string

Reason for audit logs.

Returns

Task

Exceptions

UnauthorizedException

Thrown when the client does not have the BanMembers permission.

NotFoundException

Thrown when the member does not exist.

BadRequestException

Thrown when an invalid parameter was provided.

ServerErrorException

Thrown when Discord is unable to process the request.

BanMemberAsync(ulong, TimeSpan, string?)

Bans a specified user by ID. This doesn't require the user to be in this guild.

public Task BanMemberAsync(ulong userId, TimeSpan messageDeleteDuration = default, string? reason = null)

Parameters

userId ulong

ID of the user to ban.

messageDeleteDuration TimeSpan

The duration in which discord should delete messages from the banned user.

reason string

Reason for audit logs.

Returns

Task

Exceptions

UnauthorizedException

Thrown when the client does not have the BanMembers permission.

NotFoundException

Thrown when the member does not exist.

BadRequestException

Thrown when an invalid parameter was provided.

ServerErrorException

Thrown when Discord is unable to process the request.