Browse Source

Move maxAge check to DiscordRestApiClient for consistency

pull/1140/head
Still Hsu 7 years ago
parent
commit
3dd82730d6
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
2 changed files with 2 additions and 3 deletions
  1. +2
    -0
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  2. +0
    -3
      src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs

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

@@ -957,6 +957,8 @@ namespace Discord.API
Preconditions.NotNull(args, nameof(args)); Preconditions.NotNull(args, nameof(args));
Preconditions.AtLeast(args.MaxAge, 0, nameof(args.MaxAge)); Preconditions.AtLeast(args.MaxAge, 0, nameof(args.MaxAge));
Preconditions.AtLeast(args.MaxUses, 0, nameof(args.MaxUses)); 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); options = RequestOptions.CreateOrClone(options);


var ids = new BucketIds(channelId: channelId); var ids = new BucketIds(channelId: channelId);


+ 0
- 3
src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs View File

@@ -76,9 +76,6 @@ namespace Discord.Rest
public static async Task<RestInviteMetadata> CreateInviteAsync(IGuildChannel channel, BaseDiscordClient client, public static async Task<RestInviteMetadata> CreateInviteAsync(IGuildChannel channel, BaseDiscordClient client,
int? maxAge, int? maxUses, bool isTemporary, bool isUnique, RequestOptions options) int? maxAge, int? maxUses, bool isTemporary, bool isUnique, RequestOptions options)
{ {
if (maxAge > 86400)
throw new ArgumentOutOfRangeException(paramName: nameof(maxAge), actualValue: maxAge,
message: "The maximum age of an invite must be less than or equal to a day (86400 seconds).");
var args = new API.Rest.CreateChannelInviteParams var args = new API.Rest.CreateChannelInviteParams
{ {
IsTemporary = isTemporary, IsTemporary = isTemporary,


Loading…
Cancel
Save