customContext

open override val customContext: Any?(source)

A custom object that can be inserted when creating events. By default, this is just null.

This can be used to associate a custom context with an event, e.g. like this:

class YourCustomContext(...)

val kord = Kord(token) {
gatewayEventInterceptor = DefaultGatewayEventInterceptor(
customContextCreator = { event, kord -> YourCustomContext(...) }
)
}

kord.on<MessageCreateEvent> {
// receive the value previously set when creating the event
val context = customContext as YourCustomContext
// ...
}

kord.login()

Note that Strategizable.withStrategy for Strategizable Events will copy customContext only by reference. This should be considered when inserting mutable objects into customContext.