This repository was archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Prefix
BartArys edited this page Sep 16, 2020
·
1 revision
kordx.command's prefixes are configured with PrefixConfigurations
, these allow you to set a PrefixSupplier
(suspend (event) -> String
) per context.
val prefixes = prefix {
add(MyContext) { "!" }
}
Setting a PrefixSupplier
for the CommonContext
will act as a fallback for contexts that don't have their own PrefixSupplier
.
val prefixes = prefix {
add(CommonContext) { "++" } //Since `MyContext` does not have its own supplier, it will default to this supplier
add(AnotherContext) { "!" } // `AnotherContext` has its own supplier, so it will choose this one rather than the common one.
}
You can add a PrefixConfiguration
to the ProcessorBuilder
manually:
fun ProcessorBuilder.addConfiguration(config: PrefixConfiguration) {
prefix {
config.apply()
}
}
Alternatively you can use Autowiring to do it automatically.