24 lines
730 B
Kotlin
24 lines
730 B
Kotlin
package nl.voidcorp.discord
|
|
|
|
import net.dv8tion.jda.api.entities.Activity
|
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
|
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder
|
|
import nl.voidcorp.discord.storage.ConfigStore
|
|
import org.springframework.stereotype.Service
|
|
|
|
|
|
@Service
|
|
class Loader(listeners: List<ListenerAdapter>, store: ConfigStore) {
|
|
init {
|
|
val token = System.getenv("DISCORD_TOKEN") ?: throw RuntimeException("'DISCORD_TOKEN' not set!")
|
|
val builder = DefaultShardManagerBuilder.createDefault(token)
|
|
|
|
|
|
builder.addEventListeners(listeners)
|
|
|
|
jda = builder.build()
|
|
jda.setActivityProvider {
|
|
Activity.playing("v${store.version} ($it)")
|
|
}
|
|
}
|
|
} |