mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-01 08:39:31 +01:00
Map deletes as well
This commit is contained in:
parent
671c006af3
commit
65d1241dd9
@ -31,6 +31,7 @@ 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.WebhookMessageDeleteAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateRequest;
|
||||
@ -143,11 +144,15 @@ public abstract class AbstractDiscordGuildMessageChannel<T extends GuildMessageC
|
||||
.thenApply(msg -> ReceivedDiscordMessageImpl.fromJDA(discordSRV, msg));
|
||||
}
|
||||
|
||||
protected WebhookMessageDeleteAction mapAction(WebhookMessageDeleteAction action) {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteMessageById(long id, boolean webhookMessage) {
|
||||
CompletableFuture<Void> future;
|
||||
if (webhookMessage) {
|
||||
future = queryWebhookClient().thenCompose(client -> client.deleteMessageById(id).submit());
|
||||
future = queryWebhookClient().thenCompose(client -> mapAction(client.deleteMessageById(id)).submit());
|
||||
} else {
|
||||
future = channel.deleteMessageById(id).submit();
|
||||
}
|
||||
|
@ -23,12 +23,15 @@ import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel;
|
||||
import com.discordsrv.api.discord.entity.channel.DiscordThreadContainer;
|
||||
import com.discordsrv.api.discord.entity.guild.DiscordGuild;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
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.api.requests.restaction.WebhookMessageCreateAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageDeleteAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -63,6 +66,11 @@ public class DiscordThreadChannelImpl extends AbstractDiscordGuildMessageChannel
|
||||
return super.mapAction(action).setThreadId(getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WebhookMessageDeleteAction mapAction(WebhookMessageDeleteAction action) {
|
||||
return super.mapAction(action).setThreadId(getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull DiscordGuild getGuild() {
|
||||
return guild;
|
||||
@ -83,6 +91,12 @@ public class DiscordThreadChannelImpl extends AbstractDiscordGuildMessageChannel
|
||||
return channel;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JDA jda = JDABuilder.createDefault("token").build();
|
||||
|
||||
WebhookClient.createClient(jda, "url").sendMessage("hello").setThreadId(1234567890L).queue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscordChannelType getType() {
|
||||
ChannelType type = channel.getType();
|
||||
|
Loading…
Reference in New Issue
Block a user