|
1 | 1 | package net.javadiscord.javabot.util; |
2 | 2 |
|
3 | | -import net.dv8tion.jda.api.entities.GuildMessageChannel; |
4 | | -import net.dv8tion.jda.api.entities.Message; |
5 | | -import net.dv8tion.jda.api.entities.MessageEmbed; |
6 | | -import net.dv8tion.jda.api.entities.ThreadChannel; |
7 | | -import net.dv8tion.jda.api.interactions.components.ActionRow; |
8 | | -import net.dv8tion.jda.api.interactions.components.ItemComponent; |
9 | | -import net.dv8tion.jda.api.requests.restaction.MessageAction; |
10 | | - |
11 | 3 | import java.util.ArrayList; |
12 | | -import java.util.EnumSet; |
13 | 4 | import java.util.List; |
14 | 5 | import java.util.concurrent.CompletableFuture; |
15 | 6 | import java.util.function.Consumer; |
16 | 7 |
|
17 | 8 | import org.jetbrains.annotations.NotNull; |
18 | 9 |
|
| 10 | +import net.dv8tion.jda.api.entities.Message; |
| 11 | +import net.dv8tion.jda.api.entities.MessageEmbed; |
| 12 | +import net.dv8tion.jda.api.entities.StandardGuildMessageChannel; |
| 13 | +import net.dv8tion.jda.api.entities.ThreadChannel; |
| 14 | +import net.dv8tion.jda.api.interactions.components.ActionRow; |
| 15 | +import net.dv8tion.jda.api.interactions.components.ItemComponent; |
| 16 | +import net.dv8tion.jda.api.requests.restaction.MessageAction; |
| 17 | + |
19 | 18 | /** |
20 | 19 | * Utility class for message actions. |
21 | 20 | */ |
@@ -85,15 +84,14 @@ public static CompletableFuture<Message> addAttachmentsAndSend(Message message, |
85 | 84 | * @param messages The messages to copy. |
86 | 85 | * @param onFinish A callback to execute when copying is done. |
87 | 86 | */ |
88 | | - public static void copyMessagesToNewThread(GuildMessageChannel targetChannel, @NotNull MessageEmbed infoEmbed, String newThreadName, List<Message> messages, Consumer<ThreadChannel> onFinish) { |
| 87 | + public static void copyMessagesToNewThread(StandardGuildMessageChannel targetChannel, @NotNull MessageEmbed infoEmbed, String newThreadName, List<Message> messages, Consumer<ThreadChannel> onFinish) { |
89 | 88 | targetChannel.sendMessageEmbeds(infoEmbed).queue( |
90 | 89 | message -> message.createThreadChannel(newThreadName).queue( |
91 | 90 | thread -> { |
92 | | - messages.forEach(m -> { |
93 | | - String messageContent = m.getContentRaw(); |
94 | | - if (messageContent.trim().length() == 0) messageContent = "[attachment]"; |
95 | | - MessageActionUtils.addAttachmentsAndSend(m, thread.sendMessage(messageContent) |
96 | | - .allowedMentions(EnumSet.of(Message.MentionType.EMOJI, Message.MentionType.CHANNEL))); |
| 91 | + WebhookUtil.ensureWebhookExists(targetChannel, wh->{ |
| 92 | + messages.forEach(m -> { |
| 93 | + WebhookUtil.mirrorMessageToWebhook(wh, m, m.getContentRaw(), thread.getIdLong()); |
| 94 | + }); |
97 | 95 | }); |
98 | 96 | onFinish.accept(thread); |
99 | 97 | } |
|
0 commit comments