Add an upper limit to prune length when banning a user (#611)
Messages may only be pruned between 0 and 7 days, otherwise a 400 will be thrown.
This commit is contained in:
committed by
RogueException
parent
8d9e11c08a
commit
660d4b0bf6
@@ -65,8 +65,10 @@ namespace Discord
|
||||
/// <summary> Gets a collection of all users banned on this guild. </summary>
|
||||
Task<IReadOnlyCollection<IBan>> GetBansAsync(RequestOptions options = null);
|
||||
/// <summary> Bans the provided user from this guild and optionally prunes their recent messages. </summary>
|
||||
/// <param name="pruneDays">The number of days to remove messages from this user for - must be between [0, 7]</param>
|
||||
Task AddBanAsync(IUser user, int pruneDays = 0, RequestOptions options = null);
|
||||
/// <summary> Bans the provided user id from this guild and optionally prunes their recent messages. </summary>
|
||||
/// <param name="pruneDays">The number of days to remove messages from this user for - must be between [0, 7]</param>
|
||||
Task AddBanAsync(ulong userId, int pruneDays = 0, RequestOptions options = null);
|
||||
/// <summary> Unbans the provided user if it is currently banned. </summary>
|
||||
Task RemoveBanAsync(IUser user, RequestOptions options = null);
|
||||
|
||||
@@ -798,7 +798,8 @@ namespace Discord.API
|
||||
Preconditions.NotEqual(guildId, 0, nameof(guildId));
|
||||
Preconditions.NotEqual(userId, 0, nameof(userId));
|
||||
Preconditions.NotNull(args, nameof(args));
|
||||
Preconditions.AtLeast(args.DeleteMessageDays, 0, nameof(args.DeleteMessageDays));
|
||||
Preconditions.AtLeast(args.DeleteMessageDays, 0, nameof(args.DeleteMessageDays), "Prune length must be within [0, 7]");
|
||||
Preconditions.AtMost(args.DeleteMessageDays, 7, nameof(args.DeleteMessageDays), "Prune length must be within [0, 7]");
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
|
||||
var ids = new BucketIds(guildId: guildId);
|
||||
|
||||
Reference in New Issue
Block a user