Skip to content

Commit 96a93ea

Browse files
Used MessageHistory instead of relying on ThreadChannel#getLatestMessageId
1 parent 5340c80 commit 96a93ea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/net/javadiscord/javabot/systems/help/HelpForumUpdater.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ public void execute() {
4646
}
4747

4848
private void checkForumPost(@NotNull ThreadChannel post, HelpConfig config) {
49-
post.retrieveMessageById(post.getLatestMessageId()).queue(latest -> {
49+
post.getHistory().retrievePast(1).queue(messages -> {
50+
if (messages.isEmpty()) {
51+
log.error("Could not find messages in forum thread {}", post.getId());
52+
return;
53+
}
54+
Message latest = messages.get(0);
5055
long minutesAgo = (Instant.now().getEpochSecond() - latest.getTimeCreated().toEpochSecond()) / 60;
5156
boolean isThankMessage = isThanksMessage(latest);
5257
if (minutesAgo > config.getInactivityTimeoutMinutes() || minutesAgo > config.getRemoveThanksTimeoutMinutes() && isThankMessage) {
@@ -59,7 +64,7 @@ private void checkForumPost(@NotNull ThreadChannel post, HelpConfig config) {
5964
post.getName(), post.getOwnerId(), minutesAgo);
6065
});
6166
}
62-
}, e -> log.error("Could not find message with id {}", post.getLatestMessageId()));
67+
}, e -> log.error("Could not find latest message in forum thread {}", post.getId()));
6368
}
6469

6570
private boolean isThanksMessage(@NotNull Message m) {

0 commit comments

Comments
 (0)