Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
BartArys edited this page Sep 16, 2020 · 1 revision

Setting a prefix for a specific context

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 prefix for every context

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.
}

Registering your prefix configuration

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.

Clone this wiki locally