fix concurrency and ack
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-09-05 12:49:37 +02:00
parent 5015e82700
commit 0c575378f3
6 changed files with 146 additions and 84 deletions

View File

@@ -51,9 +51,28 @@ public class CommandService
return;
}
// delete the message
event.getInteraction().getMessage().delete().queue();
// no need to manually untrack it from database, it will be purged on the next planned check.
// Acknowledge immediately so the interaction token stays valid
event.deferEdit().queue(hook -> {
// Try deleting via the interaction webhook (works for original interaction responses)
hook.deleteOriginal().queue(
success -> { /* optional: databaseService.untrackExpiredMessage(event.getMessageId()); */ },
failure -> {
// Fallback to channel delete (works even if webhook token expired)
event.getChannel().deleteMessageById(event.getMessageId()).queue(
null,
__ -> { /* ignore if already deleted */ }
);
}
);
},
failure -> {
// If we failed to acknowledge (interaction already expired), try channel delete anyway
event.getChannel().deleteMessageById(event.getMessageId()).queue(
null,
__ -> { /* ignore if already deleted */ }
);
}
);
}