예제 #1
0
파일: CommandMap.php 프로젝트: nkreer/Fish
 /**
  * @param CommandInterface $command
  * @param Plugin|null $plugin
  * @return bool
  */
 public function registerCommand(CommandInterface $command, Plugin $plugin = null) : bool
 {
     if (!$this->hasCommand($command->getCommand())) {
         $ev = new CommandRegisterEvent($command);
         $this->connection->getEventHandler()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $this->commands[$command->getCommand()] = $command;
             foreach ($command->getAliases() as $alias) {
                 if (!$this->hasCommand($alias)) {
                     $this->commands[$alias] = $command;
                 }
             }
             if ($plugin instanceof Plugin) {
                 $this->plugins[$plugin->name][$command->getCommand()] = $command;
             }
             return true;
         }
     }
     return false;
 }