3 namespace App\DiscordBotCommands;
5 use App\Models\DiscordBotCommand;
7 use Discord\Parts\Channel\Channel;
8 use Discord\Parts\Channel\Message;
9 use Discord\Parts\User\Member;
11 class ResultCommand extends BaseCommand {
13 public function __construct(Discord $discord, DiscordBotCommand $cmd) {
14 parent::__construct($discord, $cmd);
17 public function execute() {
18 if (!$this->hasRoundChannels()) {
19 return \React\Promise\resolve();
21 return $this->fetchRoundChannel()
22 ->then(function (Channel $channel) {
23 return $this->fetchMember();
25 ->then(function (Member $member) {
26 return $this->roundChannel->setPermissions($member, [
31 $user = $this->getUser();
32 $round = $this->getRound();
33 $result = $user->findResult($round);
35 if (!$result || $result->forfeit) {
36 $msg = __('discord_commands.result.forfeit', ['name' => $user->getName()]);
38 $msg = __('discord_commands.result.finish', ['name' => $user->getName(), 'time' => $result->formatTime()]);
40 return $this->roundChannel->sendMessage($msg);