Skip to content

Commit

Permalink
Add respondLaterAsEphemeralIf(...) methods to NexusCommandEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
ShindouMihou committed Mar 9, 2022
1 parent 4552c98 commit e6398eb
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -202,4 +203,30 @@ default CompletableFuture<InteractionOriginalResponseUpdater> 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<InteractionOriginalResponseUpdater> 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<InteractionOriginalResponseUpdater> respondLaterAsEphemeralIf(Predicate<Void> predicate) {
return respondLaterAsEphemeralIf(predicate.test(null));
}

}

0 comments on commit e6398eb

Please sign in to comment.