diff --git a/src/main/java/pw/mihou/nexus/features/command/facade/NexusCommandEvent.java b/src/main/java/pw/mihou/nexus/features/command/facade/NexusCommandEvent.java index eb7482c2..77e27a21 100755 --- a/src/main/java/pw/mihou/nexus/features/command/facade/NexusCommandEvent.java +++ b/src/main/java/pw/mihou/nexus/features/command/facade/NexusCommandEvent.java @@ -19,6 +19,7 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; public interface NexusCommandEvent { @@ -202,4 +203,30 @@ default CompletableFuture respondLaterAsEphe .getEphemereal(getBaseEvent().getInteraction()); } + /** + * Gets the {@link InteractionOriginalResponseUpdater} associated with this command with the ephemeral flag + * attached if the predicate is true. + * + * @param predicate The predicate to determine whether to use ephemeral response or not. + * @return The {@link InteractionOriginalResponseUpdater} for this interaction. + */ + default CompletableFuture respondLaterAsEphemeralIf(boolean predicate) { + if (predicate) { + return respondLaterAsEphemeral(); + } + + return respondLater(); + } + + /** + * Gets the {@link InteractionOriginalResponseUpdater} associated with this command with the ephemeral flag + * attached if the predicate is true. + * + * @param predicate The predicate to determine whether to use ephemeral response or not. + * @return The {@link InteractionOriginalResponseUpdater} for this interaction. + */ + default CompletableFuture respondLaterAsEphemeralIf(Predicate predicate) { + return respondLaterAsEphemeralIf(predicate.test(null)); + } + }