preCallHooks property
getter/setter pairoverride-getter
An iterable of callbacks executed before a command is executed but after all the checks for that command have succeeded.
These callbacks should be used to update this check's state.
You might also be interested in:
- CallHooked.onPreCall, for registering arbitrary callbacks to be executed before a command is executed but after all checks have succeeded;
- CommandsPlugin.onCommandError, where a CheckFailedException is added when a check for a command fails.
Implementation
@override
late Iterable<void Function(CommandContext)> preCallHooks = [
(context) {
int key = getKey(context);
if (_previousBucket.containsKey(key) && _isActive(_previousBucket[key]!)) {
_previousBucket[key]!.count++;
} else if (_currentBucket.containsKey(key)) {
_currentBucket[key]!.count++;
} else {
_currentBucket[key] = _BucketEntry(DateTime.now());
}
}
];