customContext
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()
Content copied to clipboard
Note that Strategizable.withStrategy for Strategizable Events will copy customContext only by reference. This should be considered when inserting mutable objects into customContext.