Class DiscordUtils
-
Method Summary
Modifier and TypeMethodDescriptioncompleter
(CompletableFuture<Void> future) static Instant
dateTimeFromSnowflake
(long snowflake) Gets an Instant from a Discord Snowflake.static <T> BiConsumer
<Result, T> returningCompleter
(CompletableFuture<T> future)
-
Method Details
-
completer
Creates aConsumer
that takes aResult
and then completes aCompletableFuture
.The future is completely normally with a
null
value, if and only if theResult
isResult.OK
.In any other case it is completed exceptionally with a
GameSDKException
wrapping theResult
.This method is mainly intended for chaining SDK calls together, so that one executes after another completed.
- Parameters:
future
- ACompletableFuture
that should be completed- Returns:
- A
Consumer
completing the future - See Also:
-
returningCompleter
Creates aBiConsumer
that takes aResult
and then completes aCompletableFuture
.The future is completely normally with the value passed to the
BiConsumer
, if and only if theResult
isResult.OK
.In any other case it is completed exceptionally with a
GameSDKException
wrapping theResult
.This method is mainly intended for chaining SDK calls together, so that one executes after another completed.
- Type Parameters:
T
- Type of the returned value (not theResult
, but the other value)- Parameters:
future
- ACompletableFuture
that should be completed- Returns:
- A
BiConsumer
completing the future - See Also:
-
dateTimeFromSnowflake
Gets an Instant from a Discord Snowflake.Discord Snowflakes are used for all sorts of IDs (e.g. User ID, Lobby ID). They contain information about the time they were created, which this methods extracts.
- Parameters:
snowflake
- A Discord Snowflake- Returns:
- The
Instant
at which the Discord object (User, Lobby, etc.) was created - See Also:
-