blob: 27b0b1014e306798e539d795899afcd9fe2d3f35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package com.romangraef.jdacommander
import java.util.concurrent.CompletableFuture
import java.util.function.BooleanSupplier
import java.util.function.Consumer
import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.requests.RestAction
class SyncRestAction<I>(private val jda: JDA, private val value: I) : RestAction<I> {
override fun getJDA(): JDA = jda
override fun setCheck(checks: BooleanSupplier?): RestAction<I> {
// No need for last Second checks.
// We don't execute HTTP requests anyways.
return this
}
override fun queue(success: Consumer<in I>?, failure: Consumer<in Throwable>?) {
success?.accept(value)
}
override fun complete(shouldQueue: Boolean): I = value
override fun submit(shouldQueue: Boolean): CompletableFuture<I> =
CompletableFuture.supplyAsync { value }
}
|