Slackwolf\Game\Command\JoinCommand::fire PHP Method

fire() public method

public fire ( )
    public function fire()
    {
        $userId = $this->userId;
        $game = $this->game;
        $this->client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) {
            return $channel->getMembers();
        })->then(function (array $users) use($userId, $game) {
            foreach ($users as $key => $user) {
                /* @var $user \Slack\User */
                if ($user->getId() == $this->userId) {
                    if ($this->game->addLobbyPlayer($user)) {
                        $playersList = PlayerListFormatter::format($this->game->getLobbyPlayers());
                        $this->gameManager->sendMessageToChannel($this->game, "Current lobby: " . $playersList);
                    } else {
                        $this->gameManager->sendMessageToChannel($this->game, "You've already joined, " . $user->getFirstName() . ". Stop trying to spam everyone.");
                    }
                }
            }
        });
    }