-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for auto-deferring responses (#14)
* fix: wrong function name * add: better and generalized response interface * add: auto-defer command responses * fix: readme * fix: missing delegate for NexusMiddlewareEventCore * fix: ephemeral for deferred in auto-defer not working * add: additional measure against random defers whilst scheduled defer
- Loading branch information
1 parent
8c06dea
commit 8ac5933
Showing
18 changed files
with
523 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
...java/pw/mihou/nexus/configuration/modules/NexusCommonsInterceptorsMessageConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
package pw.mihou.nexus.configuration.modules | ||
|
||
import pw.mihou.nexus.features.command.facade.NexusCommandEvent | ||
import pw.mihou.nexus.features.messages.facade.NexusMessage | ||
import pw.mihou.nexus.features.messages.NexusMessage | ||
|
||
class NexusCommonsInterceptorsMessageConfiguration internal constructor() { | ||
|
||
@set:JvmName("setRatelimitedMessage") | ||
@get:JvmName("getRatelimitedMessage") | ||
@Volatile | ||
var ratelimited: (event: NexusCommandEvent, remainingSeconds: Long) -> NexusMessage = { _, remainingSeconds -> | ||
NexusMessage.fromEphemereal( | ||
"**SLOW DOWN***!" | ||
+ "\n" | ||
+ "You are executing commands too fast, please try again in $remainingSeconds seconds." | ||
) | ||
NexusMessage.with(true) { | ||
this.setContent("***SLOW DOWN***!\nYou are executing commands too fast, please try again in $remainingSeconds seconds.") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/pw/mihou/nexus/configuration/modules/NexusLaunchConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
package pw.mihou.nexus.configuration.modules | ||
|
||
import pw.mihou.nexus.core.threadpool.NexusThreadPool | ||
import java.util.concurrent.TimeUnit | ||
|
||
class NexusLaunchConfiguration internal constructor() { | ||
@JvmField var launcher: NexusLaunchWrapper = NexusLaunchWrapper { task -> | ||
NexusThreadPool.executorService.submit { task.run() } | ||
} | ||
@JvmField var scheduler: NexusScheduledLaunchWrapper = NexusScheduledLaunchWrapper { timeInMillis, task -> | ||
NexusThreadPool.scheduledExecutorService.schedule(task::run, timeInMillis, TimeUnit.MILLISECONDS) | ||
} | ||
} | ||
|
||
fun interface NexusLaunchWrapper { | ||
fun launch(task: NexusLaunchTask) | ||
} | ||
|
||
fun interface NexusScheduledLaunchWrapper { | ||
fun launch(timeInMillis: Long, task: NexusLaunchTask) | ||
} | ||
|
||
fun interface NexusLaunchTask { | ||
fun run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.