feature: Add invite maxAge check before attempting to create the invite (#1140)

* Add maxage check & improve maxage parameter check

* Change InvalidOperation to ArgumentOoR

* Remove HasValue check
...since it does it implicitly already.

* Add parameter names & better wording for invite OoR

* Move maxAge check to DiscordRestApiClient for consistency
This commit is contained in:
Still Hsu
2018-10-21 00:45:05 +08:00
committed by Christopher F
parent f549da50e0
commit 649a779c23
2 changed files with 9 additions and 3 deletions

View File

@@ -978,6 +978,8 @@ namespace Discord.API
Preconditions.NotNull(args, nameof(args));
Preconditions.AtLeast(args.MaxAge, 0, nameof(args.MaxAge));
Preconditions.AtLeast(args.MaxUses, 0, nameof(args.MaxUses));
Preconditions.AtMost(args.MaxAge, 86400, nameof(args.MaxAge),
"The maximum age of an invite must be less than or equal to a day (86400 seconds).");
options = RequestOptions.CreateOrClone(options);
var ids = new BucketIds(channelId: channelId);