mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-25 17:08:27 +01:00
Fix webhook support
This commit is contained in:
parent
d6a21b6fca
commit
3d6c7f72de
@ -53,7 +53,8 @@ subprojects {
|
||||
includeGroup 'me.scarsz'
|
||||
includeGroup 'me.minecraftauth'
|
||||
|
||||
includeGroup 'org.spongepowered' // Configurate yamlbranch
|
||||
includeGroup 'org.spongepowered' // SpongePowered/Configurate feature/yaml-improvements branch
|
||||
includeGroup 'net.dv8tion' // DiscordSRV/JDA v5-webhooks branch
|
||||
}
|
||||
}
|
||||
maven {
|
||||
|
@ -56,6 +56,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.BiConsumer;
|
||||
@ -523,10 +524,11 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
|
||||
return textChannel.createWebhook("DSRV").submit();
|
||||
}).thenApply(webhook ->
|
||||
WebhookClientBuilder.fromJDA(webhook)
|
||||
.setHttpClient(jda.getHttpClient())
|
||||
.setExecutorService(discordSRV.scheduler().scheduledExecutorService())
|
||||
.build()
|
||||
WebhookClient.createClient(
|
||||
webhook.getJDA(),
|
||||
webhook.getId(),
|
||||
Objects.requireNonNull(webhook.getToken())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,11 @@ public abstract class AbstractDiscordGuildMessageChannel<T extends GuildMessageC
|
||||
|
||||
CompletableFuture<R> createRequest;
|
||||
if (message.isWebhookMessage()) {
|
||||
createRequest = queryWebhookClient().thenApply(client -> (R) client.sendMessage(createData));
|
||||
createRequest = queryWebhookClient()
|
||||
.thenApply(client -> (R) client.sendMessage(createData)
|
||||
.setUsername(message.getWebhookUsername())
|
||||
.setAvatarUrl(message.getWebhookAvatarUrl())
|
||||
);
|
||||
} else {
|
||||
createRequest = CompletableFuture.completedFuture(((R) channel.sendMessage(createData)));
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ 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.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.internal.requests.IncomingWebhookClient;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -52,7 +53,7 @@ public class DiscordThreadChannelImpl extends AbstractDiscordGuildMessageChannel
|
||||
public CompletableFuture<WebhookClient<Message>> queryWebhookClient() {
|
||||
return discordSRV.discordAPI()
|
||||
.queryWebhookClient(getParentChannel().getId())
|
||||
.thenApply(client -> null/* client.onThread(getId())*/); // TODO
|
||||
.thenApply(client -> ((IncomingWebhookClient) client).withThreadId(Long.toUnsignedString(getId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,7 @@ public class ReceivedDiscordMessageImpl implements ReceivedDiscordMessage {
|
||||
);
|
||||
|
||||
if (clientFuture != null) {
|
||||
long clientId = clientFuture.join().getId(); // TODO
|
||||
long clientId = clientFuture.join().getIdLong();
|
||||
self = clientId == user.getId();
|
||||
}
|
||||
} else {
|
||||
|
@ -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')
|
||||
library('jda', 'net.dv8tion', 'JDA').version('5.0.0-beta.10.webhooks_2')
|
||||
library('okhttp', 'com.squareup.okhttp3', 'okhttp').version {
|
||||
prefer '3.14.9'
|
||||
reject '[4,)' // Kotlin
|
||||
|
Loading…
Reference in New Issue
Block a user