From b917a8c18fb8bb5abf437b04a76fdf8624fde067 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sat, 13 Jan 2024 14:03:24 +0100 Subject: [PATCH] Optimize message retrieval in CommandDataSuggestions The logic in CommandDataSuggestions has been simplified to improve fetching of parent messages in thread channels. This change replaces the previous method that got the entire history and checked conditionally for size. Now, instead, the parent message is directly retrieved, leading to cleaner and more efficient code. --- .../commandManager/commands/CommandDataSuggestions.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/alttd/commandManager/commands/CommandDataSuggestions.java b/src/main/java/com/alttd/commandManager/commands/CommandDataSuggestions.java index 58afe7e..3de2d9c 100644 --- a/src/main/java/com/alttd/commandManager/commands/CommandDataSuggestions.java +++ b/src/main/java/com/alttd/commandManager/commands/CommandDataSuggestions.java @@ -48,12 +48,7 @@ public class CommandDataSuggestions extends DiscordCommand { ExcelWriter excelWriter = new ExcelWriter(); long waitSeconds = 0; for (ThreadChannel activeSuggestion : activeSuggestions) { - activeSuggestion.getHistoryFromBeginning(1).queueAfter(waitSeconds, TimeUnit.SECONDS, hist -> { - List retrievedHistory = hist.getRetrievedHistory(); - if (retrievedHistory.size() != 1) { - return; - } - Message message = retrievedHistory.get(0); + activeSuggestion.retrieveParentMessage().queueAfter(waitSeconds, TimeUnit.SECONDS, message -> { MessageReaction thumbsUp = message.getReaction(Emoji.fromUnicode("\uD83D\uDC4D")); MessageReaction thumbsDown = message.getReaction(Emoji.fromUnicode("\uD83D\uDC4E")); excelWriter.addRow(