Add method to retrieve event handlers by command

This commit is contained in:
netkas 2024-11-04 01:16:35 -05:00
parent 1cf82401c3
commit 53824b7126

View file

@ -289,6 +289,27 @@
return $results;
}
/**
* Retrieves an array of event handlers that correspond to the specified command.
*
* @param string $command The command to filter the event handlers by.
* @return array The array of event handlers that match the specified command.
*/
public function getEventHandlersByCommand(string $command): array
{
$results = [];
/** @var UpdateEvent $eventHandler */
foreach($this->eventHandlers as $eventHandler)
{
if(strtolower($eventHandler::getCommand()) === strtolower($command))
{
$results[] = $eventHandler;
}
}
return $results;
}
/**
* Removes all event handlers.
*