From 084774e56c5390959b8d930366a6a6d9f5798725 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 4 May 2025 15:48:24 +0100 Subject: [PATCH] Don't allow registering the same command instance twice --- src/command/SimpleCommandMap.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/command/SimpleCommandMap.php b/src/command/SimpleCommandMap.php index 2e4d623ef..7306b5650 100644 --- a/src/command/SimpleCommandMap.php +++ b/src/command/SimpleCommandMap.php @@ -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));