Prefix - kordlib/kordx.commands GitHub Wiki
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.