Skip to content

Commit

Permalink
fix: Remove erroneous call and perform validation
Browse files Browse the repository at this point in the history
  • Loading branch information
VelvetToroyashi committed Sep 7, 2023
1 parent c22ca67 commit 0a22fc8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ Task<Result> SetVoiceChannelStatusAsync
/// <param name="appliedTags">The tags applied to the thread.</param>
/// <param name="defaultSortOrder">The default sort order of posts.</param>
/// <param name="defaultForumLayout">The default layout of posts in a forum.</param>
/// <param name="status">The new status of the voice channel.</param>
/// <param name="reason">The reason to mark the action in the audit log with.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A modification result which may or may not have succeeded.</returns>
Expand Down Expand Up @@ -139,7 +138,6 @@ Task<Result<IChannel>> ModifyChannelAsync
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
Optional<SortOrder> defaultSortOrder = default,
Optional<ForumLayout> defaultForumLayout = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public async Task<Result<IChannel>> ModifyChannelAsync
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
Optional<SortOrder> defaultSortOrder = default,
Optional<ForumLayout> defaultForumLayout = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ public virtual Task<Result> SetVoiceChannelStatusAsync
CancellationToken ct = default
)
{
if (status is { HasValue: true, Value: { Length: > 500 } })
{
return Task.FromResult<Result>(new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters."));
}

return this.RestHttpClient.PatchAsync
(
$"channels/{channelID}/voice-status",
b => b.WithRateLimitContext(this.RateLimitCache),
b => b.WithJson(b => b.Write("status", status, this.JsonOptions)).WithRateLimitContext(this.RateLimitCache),
ct: ct
);
}
Expand Down Expand Up @@ -126,7 +131,6 @@ public virtual async Task<Result<IChannel>> ModifyChannelAsync
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
Optional<SortOrder> defaultSortOrder = default,
Optional<ForumLayout> defaultForumLayout = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
)
Expand Down Expand Up @@ -173,11 +177,6 @@ public virtual async Task<Result<IChannel>> ModifyChannelAsync
return Result<IChannel>.FromError(packImage);
}

if (status is { HasValue: true, Value: { Length: > 500 } })
{
return new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters.");
}

Optional<string> base64EncodedIcon = packImage.Entity!;

return await this.RestHttpClient.PatchAsync<IChannel>
Expand Down Expand Up @@ -219,7 +218,6 @@ public virtual async Task<Result<IChannel>> ModifyChannelAsync
json.Write("applied_tags", appliedTags, this.JsonOptions);
json.Write("default_sort_order", defaultSortOrder, this.JsonOptions);
json.Write("default_forum_layout", defaultForumLayout, this.JsonOptions);
json.Write("status", status, this.JsonOptions);
}
)
.WithRateLimitContext(this.RateLimitCache),
Expand Down

0 comments on commit 0a22fc8

Please sign in to comment.