Browse Source

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.
tags/1.0.0-rc2
Christopher F RogueException 8 years ago
parent
commit
660d4b0bf6
2 changed files with 4 additions and 1 deletions
  1. +2
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +2
    -1
      src/Discord.Net.Rest/DiscordRestApiClient.cs

+ 2
- 0
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -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);


+ 2
- 1
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -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);


Loading…
Cancel
Save