File tree 2 files changed +43
-1
lines changed
src/main/kotlin/com/mrkirby153/botcore/spring/config
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,20 @@ annotation class EnableBot
14
14
* Automatically discover and register slash commands
15
15
*/
16
16
@Import(DslCommandExecutorRegister ::class )
17
+ @Target(AnnotationTarget .CLASS )
17
18
annotation class RegisterSlashCommands
18
19
19
20
/* *
20
21
* Enables built-in autocomplete for spring jpa entities
21
22
*/
22
23
@Import(JpaArgumentConfig ::class )
23
- annotation class EnableJpaAutocomplete
24
+ @Target(AnnotationTarget .CLASS )
25
+ annotation class EnableJpaAutocomplete
26
+
27
+
28
+ /* *
29
+ * Enables the built-in modal manager
30
+ */
31
+ @Import(ModalManagerConfiguration ::class )
32
+ @Target(AnnotationTarget .CLASS )
33
+ annotation class EnableModalManager
Original file line number Diff line number Diff line change
1
+ package com.mrkirby153.botcore.spring.config
2
+
3
+ import com.mrkirby153.botcore.modal.ModalManager
4
+ import com.mrkirby153.botcore.spring.event.BotReadyEvent
5
+ import com.mrkirby153.botcore.utils.SLF4J
6
+ import net.dv8tion.jda.api.sharding.ShardManager
7
+ import org.springframework.beans.factory.annotation.Value
8
+ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
9
+ import org.springframework.context.annotation.Bean
10
+ import org.springframework.context.annotation.Configuration
11
+ import org.springframework.context.event.EventListener
12
+ import java.util.concurrent.TimeUnit
13
+
14
+ @Configuration
15
+ open class ModalManagerConfiguration (
16
+ private val shardManager : ShardManager ,
17
+ @Value(" \$ {bot.modal.gcPeriod:1}" ) private val time : Long ,
18
+ @Value(" \$ {bot.modal.gcUnit:SECOND}" ) private val unit : TimeUnit ,
19
+ ) {
20
+
21
+ private val log by SLF4J
22
+
23
+ @Bean
24
+ @ConditionalOnMissingBean
25
+ open fun modalManager () = ModalManager (null , time, unit)
26
+
27
+ @EventListener
28
+ fun onReady (event : BotReadyEvent ) {
29
+ log.info(" Registering modal manager" )
30
+ shardManager.addEventListener(modalManager())
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments