invoke method

  1. @override
Future<void> invoke(
  1. MessageContext context
)
override

Parse arguments, verify checks, call execute and handle call hooks.

This method might throw uncaught CommandsExceptions and should be handled with care. Thrown exceptions will not be added to CommandsPlugin.onCommandError unless called from within a "safe" context where uncaught exceptions are caught anyways.

Implementation

@override
Future<void> invoke(MessageContext context) async {
  for (final check in checks) {
    if (!await check.check(context)) {
      throw CheckFailedException(check, context);
    }
  }

  _preCallController.add(context);

  try {
    await execute(context);
  } catch (e) {
    throw UncaughtException(e, context);
  }

  _postCallController.add(context);
}