Don't allow registering the same command instance twice

This commit is contained in:
Dylan K. Taylor 2025-05-04 15:48:24 +01:00
parent 579aecfad7
commit 084774e56c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -150,6 +150,9 @@ class SimpleCommandMap implements CommandMap{
if(count($command->getPermissions()) === 0){
throw new \InvalidArgumentException("Commands must have a permission set");
}
if(isset($this->uniqueCommands[spl_object_id($command)])){
throw new \InvalidArgumentException("This Command object has already been registered");
}
$preferredAlias = trim($preferredAlias);
$fallbackPrefix = strtolower(trim($fallbackPrefix));