diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java index dad149e1..eecf701e 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java @@ -30,6 +30,8 @@ import net.dv8tion.jda.api.entities.WebhookClient; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; +import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction; +import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction; import net.dv8tion.jda.api.utils.messages.MessageCreateData; import net.dv8tion.jda.api.utils.messages.MessageCreateRequest; import net.dv8tion.jda.api.utils.messages.MessageEditData; @@ -78,6 +80,10 @@ public abstract class AbstractDiscordGuildMessageChannel WebhookMessageCreateAction mapAction(WebhookMessageCreateAction action) { + return action; + } + @SuppressWarnings("unchecked") // Generics private > & RestAction> CompletableFuture sendInternal(SendableDiscordMessage message) { MessageCreateData createData = SendableDiscordMessageUtil.toJDASend(message); @@ -85,7 +91,7 @@ public abstract class AbstractDiscordGuildMessageChannel createRequest; if (message.isWebhookMessage()) { createRequest = queryWebhookClient() - .thenApply(client -> (R) client.sendMessage(createData) + .thenApply(client -> (R) mapAction(client.sendMessage(createData)) .setUsername(message.getWebhookUsername()) .setAvatarUrl(message.getWebhookAvatarUrl()) ); @@ -114,6 +120,10 @@ public abstract class AbstractDiscordGuildMessageChannel WebhookMessageEditAction mapAction(WebhookMessageEditAction action) { + return action; + } + @SuppressWarnings("unchecked") // Generics private > & RestAction> CompletableFuture editInternal( long id, @@ -123,7 +133,7 @@ public abstract class AbstractDiscordGuildMessageChannel editRequest; if (message.isWebhookMessage()) { - editRequest = queryWebhookClient().thenApply(client -> (R) client.editMessageById(id, editData)); + editRequest = queryWebhookClient().thenApply(client -> (R) mapAction(client.editMessageById(id, editData))); } else { editRequest = CompletableFuture.completedFuture(((R) channel.editMessageById(id, editData))); } diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java index 1dd5596e..703b9207 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java @@ -28,7 +28,8 @@ import net.dv8tion.jda.api.entities.WebhookClient; import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; -import net.dv8tion.jda.internal.requests.IncomingWebhookClient; +import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction; +import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction; import org.jetbrains.annotations.NotNull; import java.util.concurrent.CompletableFuture; @@ -49,8 +50,17 @@ public class DiscordThreadChannelImpl extends AbstractDiscordGuildMessageChannel @Override public CompletableFuture> queryWebhookClient() { return discordSRV.discordAPI() - .queryWebhookClient(getParentChannel().getId()) - .thenApply(client -> ((IncomingWebhookClient) client).withThreadId(Long.toUnsignedString(getId()))); + .queryWebhookClient(getParentChannel().getId()); + } + + @Override + protected WebhookMessageCreateAction mapAction(WebhookMessageCreateAction action) { + return super.mapAction(action).setThreadId(getId()); + } + + @Override + protected WebhookMessageEditAction mapAction(WebhookMessageEditAction action) { + return super.mapAction(action).setThreadId(getId()); } @Override diff --git a/settings.gradle b/settings.gradle index 313276d5..289b2d97 100644 --- a/settings.gradle +++ b/settings.gradle @@ -56,7 +56,7 @@ dependencyResolutionManagement { library('findbugs-annotations', 'com.google.code.findbugs', 'jsr305').version('3.0.2') // JDA - library('jda', 'net.dv8tion', 'JDA').version('5.0.0-beta.10.webhooks_2') + library('jda', 'net.dv8tion', 'JDA').version('5.0.0-beta.16') // OkHTTP library('okhttp', 'com.squareup.okhttp3', 'okhttp').version('4.11.0')