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.
This commit is contained in:
@@ -48,12 +48,7 @@ public class CommandDataSuggestions extends DiscordCommand {
|
|||||||
ExcelWriter excelWriter = new ExcelWriter();
|
ExcelWriter excelWriter = new ExcelWriter();
|
||||||
long waitSeconds = 0;
|
long waitSeconds = 0;
|
||||||
for (ThreadChannel activeSuggestion : activeSuggestions) {
|
for (ThreadChannel activeSuggestion : activeSuggestions) {
|
||||||
activeSuggestion.getHistoryFromBeginning(1).queueAfter(waitSeconds, TimeUnit.SECONDS, hist -> {
|
activeSuggestion.retrieveParentMessage().queueAfter(waitSeconds, TimeUnit.SECONDS, message -> {
|
||||||
List<Message> retrievedHistory = hist.getRetrievedHistory();
|
|
||||||
if (retrievedHistory.size() != 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Message message = retrievedHistory.get(0);
|
|
||||||
MessageReaction thumbsUp = message.getReaction(Emoji.fromUnicode("\uD83D\uDC4D"));
|
MessageReaction thumbsUp = message.getReaction(Emoji.fromUnicode("\uD83D\uDC4D"));
|
||||||
MessageReaction thumbsDown = message.getReaction(Emoji.fromUnicode("\uD83D\uDC4E"));
|
MessageReaction thumbsDown = message.getReaction(Emoji.fromUnicode("\uD83D\uDC4E"));
|
||||||
excelWriter.addRow(
|
excelWriter.addRow(
|
||||||
|
|||||||
Reference in New Issue
Block a user