on<T extends DispatchEvent> method
A helper function to listen to events of a specific type.
Specifying the type parameter is important, as the callback will otherwise be invoked for every event received by the client.
The following two code examples are equivalent:
client.on<MessageCreateEvent>((event) => print(event.message.content));
client.onMessageCreate.listen((event) => print(event.message.content));
Implementation
StreamSubscription<T> on<T extends DispatchEvent>(void Function(T event) onData) => onEvent.whereType<T>().listen(onData);