Method BanMemberAsync
- Namespace
- DisCatSharp.Entities
- Assembly
- DisCatSharp.dll
BanMemberAsync(DiscordMember, int, string?, CancellationToken)
Bans a specified DiscordMember from this guild.
public Task BanMemberAsync(DiscordMember member, int deleteMessageSeconds = 0, string? reason = null, CancellationToken cancellationToken = default)
Parameters
memberDiscordMemberMember to ban.
deleteMessageSecondsintHow many seconds to remove messages from the users. Minimum
0seconds and maximum604800seconds (7 days).reasonstringReason for audit logs.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
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(DiscordUser, int, string?, CancellationToken)
Bans a specified DiscordUser. This doesn't require the user to be in this guild.
public Task BanMemberAsync(DiscordUser user, int deleteMessageSeconds = 0, string? reason = null, CancellationToken cancellationToken = default)
Parameters
userDiscordUserThe user to ban.
deleteMessageSecondsintHow many seconds to remove messages from the users. Minimum
0seconds and maximum604800seconds (7 days).reasonstringReason for audit logs.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
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, int, string, CancellationToken)
Bans a specified user ID from this guild. This doesn't require the user to be in this guild.
public Task BanMemberAsync(ulong userId, int deleteMessageSeconds = 0, string reason = null, CancellationToken cancellationToken = default)
Parameters
userIdulongID of the user to ban.
deleteMessageSecondsintHow many seconds to remove messages from the users. Minimum
0seconds and maximum604800seconds (7 days).reasonstringReason for audit logs.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
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.