Skip to content

Commit

Permalink
Fix precondition checks. Closes discord-net#281
Browse files Browse the repository at this point in the history
  • Loading branch information
quinchs committed Nov 23, 2021
1 parent 319ae50 commit fd9b37d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Discord.Net.Rest/DiscordRestApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ public async Task<Channel> CreateGuildChannelAsync(ulong guildId, CreateGuildCha
Preconditions.NotNull(args, nameof(args));
Preconditions.GreaterThan(args.Bitrate, 0, nameof(args.Bitrate));
Preconditions.NotNullOrWhitespace(args.Name, nameof(args.Name));
Preconditions.LessThan(args.Name.Length, 100, nameof(args.Name));
Preconditions.AtMost(args.Name.Length, 100, nameof(args.Name));
if (args.Topic.IsSpecified)
Preconditions.LessThan(args.Topic.Value.Length, 1024, nameof(args.Name));
Preconditions.AtMost(args.Topic.Value.Length, 1024, nameof(args.Name));

options = RequestOptions.CreateOrClone(options);

Expand Down Expand Up @@ -375,7 +375,7 @@ public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, Rest.ModifyG
Preconditions.NotNullOrWhitespace(args.Name, nameof(args.Name));

if(args.Name.IsSpecified)
Preconditions.LessThan(args.Name.Value.Length, 100, nameof(args.Name));
Preconditions.AtMost(args.Name.Value.Length, 100, nameof(args.Name));

options = RequestOptions.CreateOrClone(options);

Expand All @@ -391,9 +391,9 @@ public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, Rest.ModifyT
Preconditions.NotNullOrWhitespace(args.Name, nameof(args.Name));

if(args.Name.IsSpecified)
Preconditions.LessThan(args.Name.Value.Length, 100, nameof(args.Name));
Preconditions.AtMost(args.Name.Value.Length, 100, nameof(args.Name));
if(args.Topic.IsSpecified)
Preconditions.LessThan(args.Topic.Value.Length, 1024, nameof(args.Name));
Preconditions.AtMost(args.Topic.Value.Length, 1024, nameof(args.Name));

Preconditions.AtLeast(args.SlowModeInterval, 0, nameof(args.SlowModeInterval));
Preconditions.AtMost(args.SlowModeInterval, 21600, nameof(args.SlowModeInterval));
Expand Down

0 comments on commit fd9b37d

Please sign in to comment.