From 6a55aa27b6da1d0e87dec9d606438880389561f9 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 20 Apr 2024 12:53:12 +0100 Subject: [PATCH] Fix #312 by ignoring already removed messages --- .../org/geysermc/discordbot/listeners/DeleteHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/geysermc/discordbot/listeners/DeleteHandler.java b/src/main/java/org/geysermc/discordbot/listeners/DeleteHandler.java index 1eae2060..6ca00156 100644 --- a/src/main/java/org/geysermc/discordbot/listeners/DeleteHandler.java +++ b/src/main/java/org/geysermc/discordbot/listeners/DeleteHandler.java @@ -41,7 +41,11 @@ public void onMessageDelete(@NotNull MessageDeleteEvent event) { if (message.getType() == MessageType.INLINE_REPLY && message.getAuthor() == event.getJDA().getSelfUser() && message.getMessageReference().getMessageId().equals(event.getMessageId())) { - message.delete().complete(); + try { + message.delete().complete(); + } catch (Exception ignored) { + // If this fails then the message is already deleted + } } } }