dispatch method
Implementation
@override
Future<void> dispatch(String customId, List params) async {
final component = _components[customId];
if (component == null) {
return;
}
try {
switch (component) {
case final InteractiveButton button when params.isNotEmpty:
await button.handle(params[0] as ButtonContext);
case final InteractiveModal modal when params.length >= 2:
await modal.handle(params[0] as ModalContext, params[1]);
case final InteractiveSelectMenu select when params.length >= 2:
await select.handle(params[0] as SelectContext, params[1]);
default:
return;
}
} on Exception catch (e, stackTrace) {
_logger
..error('Failed to dispatch component "$customId": $e')
..trace('$stackTrace');
onComponentError?.call(component, e, stackTrace);
// ignore: avoid_catching_errors, crash-safety boundary for component handlers
} on Error catch (e, stackTrace) {
_logger
..error('Failed to dispatch component "$customId": $e')
..trace('$stackTrace');
onComponentError?.call(component, e, stackTrace);
}
}