Skip to content

Commit

Permalink
Merge executeWebhook fix from 3.2.x into 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
quanticc committed Jun 25, 2022
2 parents 2d77e35 + dfdb09f commit 8868270
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions rest/src/main/java/discord4j/rest/service/WebhookService.java
Expand Up @@ -17,7 +17,6 @@
package discord4j.rest.service;

import discord4j.discordjson.json.*;
import discord4j.rest.request.DiscordWebResponse;
import discord4j.rest.request.Router;
import discord4j.rest.route.Routes;
import discord4j.rest.util.MultipartRequest;
Expand Down Expand Up @@ -108,18 +107,13 @@ public Mono<Void> deleteWebhookWithToken(long webhookId, String token) {
*/
public Mono<MessageData> executeWebhook(long webhookId, String token, boolean wait,
MultipartRequest<? extends WebhookExecuteRequest> request) {
DiscordWebResponse response = Routes.WEBHOOK_EXECUTE
return Routes.WEBHOOK_EXECUTE
.newRequest(webhookId, token)
.query("wait", wait)
.header("content-type", request.getFiles().isEmpty() ? "application/json" : "multipart/form-data")
.body(Objects.requireNonNull(request.getFiles().isEmpty() ? request.getJsonPayload() : request))
.exchange(getRouter());

if (wait) {
return response.bodyToMono(MessageData.class);
} else {
return response.bodyToMono(Void.class).cast(MessageData.class);
}
.exchange(getRouter())
.bodyToMono(MessageData.class);
}

public Mono<MessageData> getWebhookMessage(long webhookId, String webhookToken, String messageId) {
Expand Down

0 comments on commit 8868270

Please sign in to comment.