on

inline fun <T : VoiceEvent> VoiceGateway.on(scope: CoroutineScope = this.scope, crossinline consumer: suspend T.() -> Unit): Job(source)

Convenience method that will invoke the consumer on every event T created by VoiceGateway.events.

The events are buffered in an unlimited buffer and launched in the supplied scope, which is VoiceGateway by default. Each event will be launched inside the scope separately and any thrown Throwable will be caught and logged.

The returned Job is a reference to the created coroutine, call Job.cancel to cancel the processing of any further events for this consumer.