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
DiscordUserMember to ban.
messageDeleteDuration
TimeSpanThe duration in which discord should delete messages from the banned user.
reason
stringReason 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
ulongID of the user to ban.
messageDeleteDuration
TimeSpanThe duration in which discord should delete messages from the banned user.
reason
stringReason 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.