X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FDiscordBotCommands%2FResultCommand.php;fp=app%2FDiscordBotCommands%2FResultCommand.php;h=bfe35bde4bd4c114932a97ab61b2298fbbda4e56;hb=66e57699b8055ef8a65a1be55b05301c811090bb;hp=0000000000000000000000000000000000000000;hpb=a5b6f807937bc78ff991d11cff5bf9455dee9eea;p=alttp.git diff --git a/app/DiscordBotCommands/ResultCommand.php b/app/DiscordBotCommands/ResultCommand.php new file mode 100644 index 0000000..bfe35bd --- /dev/null +++ b/app/DiscordBotCommands/ResultCommand.php @@ -0,0 +1,44 @@ +hasRoundChannels()) { + return \React\Promise\resolve(); + } + return $this->fetchRoundChannel() + ->then(function (Channel $channel) { + return $this->fetchMember(); + }) + ->then(function (Member $member) { + return $this->roundChannel->setPermissions($member, [ + 'view_channel', + ]); + }) + ->then(function () { + $user = $this->getUser(); + $round = $this->getRound(); + $result = $user->findResult($round); + $msg = ''; + if (!$result || $result->forfeit) { + $msg = __('discord_commands.result.forfeit', ['name' => $user->getName()]); + } else { + $msg = __('discord_commands.result.finish', ['name' => $user->getName(), 'time' => $result->formatTime()]); + } + return $this->roundChannel->sendMessage($msg); + }); + } + +}