Skip to content

Commit

Permalink
* Improved cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Jul 18, 2022
1 parent b1ab058 commit 45388ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/events/LoggingEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public void onMessageDelete(@Nonnull MessageDeleteEvent event) {
we.setFooter(new WebhookEmbed.EmbedFooter(event.getGuild().getName() + " - " + Data.ADVERTISEMENT, event.getGuild().getIconUrl()));
we.setTimestamp(Instant.now());

Message message = ArrayUtil.getMessageFromMessageList(event.getMessageId());
Message message = ArrayUtil.getMessageFromMessageListAndRemove(event.getMessageId());

if (message != null && message.getActivity() != null) return;

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/de/presti/ree6/utils/data/ArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,17 @@ public static Message getMessageFromMessageList(String id) {
return messageIDwithMessage.get(id);
}
}

/**
* Get the Message content, of a deleted Message, by the ID.
* @param id the ID of the Message.
* @return the {@link Message} Entity of the deleted Message.
*/
public static Message getMessageFromMessageListAndRemove(String id) {
if (!messageIDwithMessage.containsKey(id)) {
return null;
} else {
return messageIDwithMessage.remove(id);
}
}
}

0 comments on commit 45388ef

Please sign in to comment.