From d76c83176cd7e9f1a8e911a41e028c7ffa2382c4 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Wed, 3 Jan 2024 19:17:30 +0100 Subject: [PATCH] fix: fix my own mistake --- DisCatSharp/DisCatSharp.csproj | 1 - DisCatSharp/Net/Rest/DiscordApiClient.cs | 7 ++++--- DisCatSharp/Net/Rest/RestClient.cs | 9 ++++++--- DisCatSharp/QueryUriBuilder.cs | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/DisCatSharp/DisCatSharp.csproj b/DisCatSharp/DisCatSharp.csproj index 88e6a87960..f5d83ec281 100644 --- a/DisCatSharp/DisCatSharp.csproj +++ b/DisCatSharp/DisCatSharp.csproj @@ -57,7 +57,6 @@ - diff --git a/DisCatSharp/Net/Rest/DiscordApiClient.cs b/DisCatSharp/Net/Rest/DiscordApiClient.cs index 8ea0accb12..6fd76ad039 100644 --- a/DisCatSharp/Net/Rest/DiscordApiClient.cs +++ b/DisCatSharp/Net/Rest/DiscordApiClient.cs @@ -293,13 +293,14 @@ private Task DoMultipartAsync( IReadOnlyDictionary? headers = null, IReadOnlyDictionary? values = null, IEnumerable? files = null, - double? ratelimitWaitOverride = null + double? ratelimitWaitOverride = null, + bool targetDebug = false ) { var req = new MultipartWebRequest(client, bucket, url, method, route, headers, values, files, ratelimitWaitOverride); if (this.Discord is not null) - this.Rest.ExecuteRequestAsync(req).LogTaskFault(this.Discord.Logger, LogLevel.Error, LoggerEvents.RestError, "Error while executing request"); + this.Rest.ExecuteRequestAsync(req, targetDebug).LogTaskFault(this.Discord.Logger, LogLevel.Error, LoggerEvents.RestError, "Error while executing request"); else _ = this.Rest.ExecuteRequestAsync(req); @@ -4705,7 +4706,7 @@ internal async Task ExecuteWebhookAsync(ulong webhookId, string var url = qub.Build(); - var res = await this.DoMultipartAsync(this.Discord, bucket, url, RestRequestMethod.POST, route, values: values, files: builder.Files).ConfigureAwait(false); + var res = await this.DoMultipartAsync(this.Discord, bucket, url, RestRequestMethod.POST, route, values: values, files: builder.Files, targetDebug: true).ConfigureAwait(false); var ret = DiscordJson.DeserializeObject(res.Response, this.Discord); if (this.Discord != null!) diff --git a/DisCatSharp/Net/Rest/RestClient.cs b/DisCatSharp/Net/Rest/RestClient.cs index 5c0cea5db8..37ee6d3590 100644 --- a/DisCatSharp/Net/Rest/RestClient.cs +++ b/DisCatSharp/Net/Rest/RestClient.cs @@ -244,8 +244,8 @@ public RateLimitBucket GetBucket(RestRequestMethod method, string route, object /// Executes the request. /// /// The request to be executed. - public Task ExecuteRequestAsync(BaseRestRequest request) - => request is null ? throw new ArgumentNullException(nameof(request)) : this.ExecuteRequestAsync(request, null, null); + public Task ExecuteRequestAsync(BaseRestRequest request, bool targetDebug = false) + => request is null ? throw new ArgumentNullException(nameof(request)) : this.ExecuteRequestAsync(request, null, null, targetDebug); /// /// Executes the form data request. @@ -461,10 +461,13 @@ private async Task ExecuteFormRequestAsync(BaseRestRequest request, RateLimitBuc /// The request to be executed. /// The bucket. /// The ratelimit task completion source. - private async Task ExecuteRequestAsync(BaseRestRequest request, RateLimitBucket? bucket, TaskCompletionSource? ratelimitTcs) + private async Task ExecuteRequestAsync(BaseRestRequest request, RateLimitBucket? bucket, TaskCompletionSource? ratelimitTcs, bool targetDebug = false) { ObjectDisposedException.ThrowIf(this._disposed, this); + if (targetDebug) + Console.WriteLine("Meow"); + HttpResponseMessage? res = default; try diff --git a/DisCatSharp/QueryUriBuilder.cs b/DisCatSharp/QueryUriBuilder.cs index 5c471ba8ac..e335650804 100644 --- a/DisCatSharp/QueryUriBuilder.cs +++ b/DisCatSharp/QueryUriBuilder.cs @@ -63,7 +63,7 @@ public QueryUriBuilder AddParameter(string key, string value) public Uri Build() => new UriBuilder(this.SourceUri) { - Query = this._queryParams.Count is 0 ? string.Join("&", this._queryParams.Select(e => Uri.EscapeDataString(e.Key) + '=' + Uri.EscapeDataString(e.Value))) : string.Empty + Query = this._queryParams.Count is not 0 ? string.Join("&", this._queryParams.Select(e => Uri.EscapeDataString(e.Key) + '=' + Uri.EscapeDataString(e.Value))) : string.Empty }.Uri; ///