Class DiscordUtils
-
Method Summary
Modifier and TypeMethodDescriptioncompleter(CompletableFuture<Void> future) static InstantdateTimeFromSnowflake(long snowflake) Gets an Instant from a Discord Snowflake.static <T> BiConsumer<Result, T> returningCompleter(CompletableFuture<T> future)
-
Method Details
-
completer
Creates aConsumerthat takes aResultand then completes aCompletableFuture.The future is completely normally with a
nullvalue, if and only if theResultisResult.OK.In any other case it is completed exceptionally with a
GameSDKExceptionwrapping theResult.This method is mainly intended for chaining SDK calls together, so that one executes after another completed.
- Parameters:
future- ACompletableFuturethat should be completed- Returns:
- A
Consumercompleting the future - See Also:
-
returningCompleter
Creates aBiConsumerthat takes aResultand then completes aCompletableFuture.The future is completely normally with the value passed to the
BiConsumer, if and only if theResultisResult.OK.In any other case it is completed exceptionally with a
GameSDKExceptionwrapping 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- ACompletableFuturethat should be completed- Returns:
- A
BiConsumercompleting 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
Instantat which the Discord object (User, Lobby, etc.) was created - See Also:
-