discord-kagebot/src/main/kotlin/moe/kageru/kagebot/features/Features.kt

20 lines
613 B
Kotlin
Raw Normal View History

package moe.kageru.kagebot.features
import moe.kageru.kagebot.config.RawFeatures
2019-07-11 20:14:22 +02:00
class Features(val welcome: WelcomeFeature?, val debug: DebugFeature?, val help: HelpFeature?) {
2019-06-15 14:15:34 +02:00
constructor(rawFeatures: RawFeatures) : this(
rawFeatures.welcome?.let(::WelcomeFeature),
2019-07-11 20:14:22 +02:00
rawFeatures.debug?.let(::DebugFeature),
rawFeatures.help?.let(::HelpFeature)
2019-06-15 14:15:34 +02:00
)
2019-07-11 20:14:22 +02:00
fun all() = listOfNotNull(this.welcome, this.debug, this.help)
fun allWithMessage() = all().filterIsInstance<MessageFeature>()
companion object {
2019-07-11 20:14:22 +02:00
val NONE = Features(null, null, null)
}
}
interface Feature