me.jakejmattson.kutils.api.dsl.configuration.StartBot.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of KUtils Show documentation
Show all versions of KUtils Show documentation
A Discord bot framework for Kotlin.
@file:Suppress("unused")
package me.jakejmattson.kutils.api.dsl.configuration
import me.jakejmattson.kutils.internal.utils.KUtils
import org.slf4j.impl.SimpleLogger
fun startBot(token: String, enableScriptEngine: Boolean = false, globalPath: String = defaultGlobalPath(Exception()), operate: KUtils.() -> Unit = {}): KUtils {
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "WARN")
val util = KUtils(KConfiguration(), token, globalPath, enableScriptEngine)
util.operate()
util.applyConfiguration.invoke()
return util
}
private fun defaultGlobalPath(exception: Exception): String {
val full = exception.stackTrace[1].className
val lastIndex = full.lastIndexOf(".").takeIf { it != -1 } ?: full.lastIndex
return full.substring(0, lastIndex)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy