-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBot.kt
30 lines (26 loc) · 1.14 KB
/
Bot.kt
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
29
30
package io.github.freya022.bot
import dev.minn.jda.ktx.jdabuilder.light
import io.github.freya022.bot.config.Config
import io.github.freya022.botcommands.api.core.JDAService
import io.github.freya022.botcommands.api.core.events.BReadyEvent
import io.github.freya022.botcommands.api.core.service.annotations.BService
import net.dv8tion.jda.api.entities.Activity
import net.dv8tion.jda.api.hooks.IEventManager
import net.dv8tion.jda.api.requests.GatewayIntent
import net.dv8tion.jda.api.utils.cache.CacheFlag
/**
* Service to start JDA at the appropriate time
*/
@BService
class Bot(private val config: Config) : JDAService() {
override val intents: Set<GatewayIntent> = defaultIntents
override val cacheFlags: Set<CacheFlag> = emptySet()
override fun createJDA(event: BReadyEvent, eventManager: IEventManager) {
// You MUST disable enableCoroutines and set the event manager to the injected one
light(config.token, intents = intents, enableCoroutines = false) {
enableCache(cacheFlags)
setActivity(Activity.customStatus("In Kotlin with \u2764\uFE0F"))
setEventManager(eventManager)
}
}
}