Package io.facet.common

Types

GatewayInteractionResponse
Link copied to clipboard
interface GatewayInteractionResponse : InteractionResponse

A handler for common operations related to an interaction followup response.

Functions

actorListener
Link copied to clipboard
inline fun <E : Event> GatewayDiscordClient.actorListener(scope: CoroutineScope, context: CoroutineContext = EmptyCoroutineContext, capacity: Int = Channel.RENDEZVOUS, start: CoroutineStart = CoroutineStart.DEFAULT, noinline onCompletion: CompletionHandler? = null, noinline block: suspend ActorScope<E>.() -> Unit): Job
inline fun <E : Event> EventDispatcher.actorListener(scope: CoroutineScope, context: CoroutineContext = EmptyCoroutineContext, capacity: Int = Channel.RENDEZVOUS, start: CoroutineStart = CoroutineStart.DEFAULT, noinline onCompletion: CompletionHandler? = null, noinline block: suspend ActorScope<E>.() -> Unit): Job

Creates and launches a new coroutine, which launches an actor coroutine and forwards gateway events of the specified type to it's ReceiveChannel.

asULong
Link copied to clipboard
fun Snowflake.asULong(): ULong
await
Link copied to clipboard
suspend fun <T : Any> Flux<T>.await(): List<T>

Suspends the current coroutine, and returns all elements emitted by the Flux in a List.

@JvmName(name = "awaitVoid")
suspend fun Flux<Void>.await()

Suspends the current coroutine, and returns when the Flux completes.

suspend fun <T : Any> Mono<T>.await(): T

Awaits for the single value from the given Mono, suspending the current coroutine and resuming when the mono emits the resulting value or throws the corresponding exception if this publisher had produced error.

@JvmName(name = "awaitVoid")
suspend fun Mono<Void>.await()

Awaits for the completion signal from the given Mono, suspending the current coroutine and resuming when the mono emits the resulting value or throws the corresponding exception if this publisher had produced error.

awaitComplete
Link copied to clipboard
suspend fun Mono<*>.awaitComplete()

Awaits for the completion signal from the given Mono, suspending the current coroutine and resuming when the mono emits the resulting value or throws the corresponding exception if this publisher had produced error.

awaitNullable
Link copied to clipboard
suspend fun <T : Any> Mono<T>.awaitNullable(): T?

Awaits for the single value from the given Mono or null value if none is emitted, suspending the current coroutine and resuming when the mono returns the resulting value or throws the corresponding exception if this publisher had produced error.

distinct
Link copied to clipboard
fun <T> Flow<T>.distinct(): Flow<T>

Returns a flow which only emits unique values of type T.

distinctBy
Link copied to clipboard
fun <T, K> Flow<T>.distinctBy(selector: (T) -> K): Flow<T>

Returns a flow which only emits unique values determined by the given selector function.

flowOf
Link copied to clipboard
inline fun <E : Event> GatewayDiscordClient.flowOf(): Flow<E>
inline fun <E : Event> EventDispatcher.flowOf(): Flow<E>

Returns a Flow of the specified event type.

getAllMemberMentions
Link copied to clipboard
suspend fun Message.getAllMemberMentions(): Set<Member>

Gets ALL distinct Member mentions, including users specifically mentioned as well as users mentioned in roles.

getAllUserMentions
Link copied to clipboard
suspend fun Message.getAllUserMentions(): Set<User>

Gets ALL distinct User mentions, including users specifically mentioned as well as users mentioned in roles.

getConnectedMemberIds
Link copied to clipboard
suspend fun VoiceChannel.getConnectedMemberIds(): Set<Snowflake>

Gets the Snowflake ids of the members currently connected to this voice channel by requesting the VoiceStates of this channel.

getConnectedMembers
Link copied to clipboard
suspend fun VoiceChannel.getConnectedMembers(): Set<Member>

Gets the members currently connected to this voice channel by requesting the VoiceStates of this channel.

getConnectedVoiceChannel
Link copied to clipboard
suspend fun Guild.getConnectedVoiceChannel(): AudioChannel?

Gets the VoiceChannel that our user is connected to in this Guild.

suspend fun Member.getConnectedVoiceChannel(): AudioChannel?

Gets the VoiceChannel that the member is currently connected to, if present.

getMembers
Link copied to clipboard
suspend fun Role.getMembers(): List<Member>

Gets the members with this role by requesting the members of this guild and filtering by this role's Snowflake ID.

getOurVoiceState
Link copied to clipboard
suspend fun Guild.getOurVoiceState(): VoiceState?

Gets the VoiceState of our user in this Guild.

getVoiceChannelByName
Link copied to clipboard
suspend fun Guild.getVoiceChannelByName(name: String): AudioChannel?

Returns the first VoiceChannel found with the specified name.

grab
Link copied to clipboard
fun <T : Any> Optional<T>.grab(): T?
listener
Link copied to clipboard
inline fun <E : Event> GatewayDiscordClient.listener(scope: CoroutineScope, context: CoroutineContext = EmptyCoroutineContext, capacity: Int = Channel.RENDEZVOUS, start: CoroutineStart = CoroutineStart.DEFAULT, crossinline block: suspend CoroutineScope.(E) -> Unit): Job
inline fun <E : Event> EventDispatcher.listener(scope: CoroutineScope, context: CoroutineContext = EmptyCoroutineContext, capacity: Int = Channel.RENDEZVOUS, start: CoroutineStart = CoroutineStart.DEFAULT, crossinline block: suspend CoroutineScope.(E) -> Unit): Job

Creates and launches a new coroutine, which listens to the specified Event type and calls the block function whenever a new event of that type is received by the gateway.

mergeWith
Link copied to clipboard
fun <T> Flow<T>.mergeWith(other: Flow<T>): Flow<T>

Merge two flows together.

on
Link copied to clipboard
inline fun <E : Event> GatewayDiscordClient.on(): Flux<E>
inline fun <E : Event> EventDispatcher.on(): Flux<E>

Helper function to make listening to discord events shorter.

reply
Link copied to clipboard
suspend fun Message.reply(spec: EmbedCreateSpec): Message

Sends a Message with an embed as a reply to the receiver, building the embed from the specified EmbedCreateSpec.

suspend fun Message.reply(spec: MessageCreateSpec): Message

Sends a Message as a reply to the receiver, building the message from the specified MessageCreateSpec.

suspend fun Message.reply(builder: MessageBuilder.() -> Unit): Message

Sends a Message as a reply to the receiver, building the message from the specified MessageBuilder.

suspend fun Message.reply(content: String, mention: Boolean = true): Message

Sends a Message as a reply to the receiver, building the message from the specified content.

replyEmbed
Link copied to clipboard
suspend fun Message.replyEmbed(mention: Boolean = true, builder: EmbedBuilder.() -> Unit): Message

Sends a Message with an embed as a reply to the receiver, building the embed from the specified EmbedBuilder.

retry
Link copied to clipboard
inline suspend fun <T> retry(n: Int, errorDelayMillis: Long, fn: (counter: Int) -> T): T
sendEmbed
Link copied to clipboard
suspend fun MessageChannel.sendEmbed(spec: EmbedCreateSpec): Message

Sends an embed in the specified channel based on the EmbedCreateSpec.

suspend fun MessageChannel.sendEmbed(block: EmbedBuilder.() -> Unit): Message

Builds an EmbedCreateSpec and sends it in the specified channel.

sendFollowupEmbed
Link copied to clipboard
suspend fun GatewayInteractionResponse.sendFollowupEmbed(build: EmbedBuilder.() -> Unit): Message

Create and send a new followup message containing an embed built from the specified builder. This uses a webhook tied to the interaction ID and token.

sendFollowupEmbedEphemeral
Link copied to clipboard
suspend fun GatewayInteractionResponse.sendFollowupEmbedEphemeral(build: EmbedBuilder.() -> Unit): Message

Create and send a new ephemeral followup message containing an embed built from the specified builder. This uses a webhook tied to the interaction ID and token.

sendFollowupMessage
Link copied to clipboard
suspend fun InteractionResponse.sendFollowupMessage(spec: EmbedCreateSpec): MessageData

Create and send a new followup message containing an embed from the specified EmbedCreateSpec. This uses a webhook tied to the interaction ID and token.

suspend fun InteractionResponse.sendFollowupMessage(spec: WebhookExecuteSpec): MessageData

Create and send a new followup message using the provided WebhookExecuteSpec. This uses a webhook tied to the interaction ID and token.

suspend fun InteractionResponse.sendFollowupMessage(build: WebhookMessageBuilder.() -> Unit): MessageData

Create and send a new followup message, using the WebhookMessageBuilder to build the request. This uses a webhook tied to the interaction ID and token.

suspend fun InteractionResponse.sendFollowupMessage(content: String): MessageData

Create and send a new followup message with the provided content. This uses a webhook tied to the interaction ID and token.

suspend fun GatewayInteractionResponse.sendFollowupMessage(spec: EmbedCreateSpec): Message

Create and send a new followup message containing an embed from the specified spec. This uses a webhook tied to the interaction ID and token.

suspend fun GatewayInteractionResponse.sendFollowupMessage(build: WebhookMessageBuilder.() -> Unit): Message

Create and send a new followup message, using the builder to build the request. This uses a webhook tied to the interaction ID and token.

sendFollowupMessageEphemeral
Link copied to clipboard

Create and send a new ephemeral followup message containing an embed from the specified spec. This uses a webhook tied to the interaction ID and token.

suspend fun GatewayInteractionResponse.sendFollowupMessageEphemeral(build: WebhookMessageBuilder.() -> Unit): Message

Create and send a new ephemeral followup message, using the builder to build the request. This uses a webhook tied to the interaction ID and token.

sendMessage
Link copied to clipboard
suspend fun MessageChannel.sendMessage(template: MessageCreateSpec): Message

Sends a message in the specified channel based on the MessageCreateSpec.

suspend fun MessageChannel.sendMessage(vararg specs: EmbedCreateSpec): Message

Sends a message with an embed in the specified channel based on the EmbedCreateSpec.

suspend fun MessageChannel.sendMessage(block: MessageBuilder.() -> Unit): Message

Builds a MessageCreateSpec and sends it in the specified channel.

suspend fun MessageChannel.sendMessage(content: String): Message

Builds a message spec with only content and sends it in the specified channel.

toMonoOrEmpty
Link copied to clipboard
fun <T : Any> T?.toMonoOrEmpty(): Mono<T>

Extension to convert a nullable type of T to a Mono that emits the supplied element when present, or complete if null.

toOptional
Link copied to clipboard
fun <T : Any> T?.toOptional(): Optional<T>

Extension function to convert a nullable type to an optional.

toSnowflake
Link copied to clipboard
fun Id.toSnowflake(): Snowflake

fun Long.toSnowflake(): Snowflake

Extension function to turn a Long into a Snowflake

fun String.toSnowflake(): Snowflake

Extension function to turn String into a Snowflake

unwrap
Link copied to clipboard
fun <T> Possible<T>.unwrap(): T?

Unwraps the D4J Possible into a nullable type.

fun <T> Optional<T>.unwrap(): T?

Unwraps an Optional to a nullable T?.

utf16
Link copied to clipboard
fun utf16(code: Int): String

Properties

allMemberMentions
Link copied to clipboard

Returns a flow that emits all members mentioned on this message.

allUserMentions
Link copied to clipboard

Gets ALL distinct User mentions, including users specifically mentioned as well as users mentioned in roles.

buttonEvents
Link copied to clipboard
val Message.buttonEvents: Flow<ButtonInteractionEvent>

Returns a flow that emits all button interactions on this message.

componentEvents
Link copied to clipboard
val Message.componentEvents: Flow<ComponentInteractionEvent>

Returns a flow that emits all component interactions on this message.

connectedMembers
Link copied to clipboard
val VoiceChannel.connectedMembers: Flow<Member>

Gets the members currently connected to this VoiceChannel by requesting the VoiceStates of this guild and filtering by this channel's Snowflake ID.

gatewayInteractionResponse
Link copied to clipboard

The handler for common operations related to an interaction followup response associated with this event.

members
Link copied to clipboard
val Role.members: Flow<Member>

Gets the members with this role by requesting the members of this guild and filtering by this role's Snowflake ID.

ourReactions
Link copied to clipboard
val Message.ourReactions: Set<Reaction>

Returns a set of all reactions that our user as added to this message.

reactionAddEvents
Link copied to clipboard
val Message.reactionAddEvents: Flow<ReactionAddEvent>

Returns a flow that emits all reaction events on this message.

selectMenuEvents
Link copied to clipboard
val Message.selectMenuEvents: Flow<SelectMenuInteractionEvent>

Returns a flow that emits all select menu interactions on this message.

unicode
Link copied to clipboard
val Int.unicode: String
value
Link copied to clipboard
val <T : Any> Optional<T>.value: T?