From: Daniel Karbach Date: Sun, 1 May 2022 13:14:54 +0000 (+0200) Subject: dispatch discord command on result report X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;ds=sidebyside;h=de6fd9ef047bda248eebec0c135f7487e781a7ae;p=alttp.git dispatch discord command on result report --- diff --git a/app/Http/Controllers/ResultController.php b/app/Http/Controllers/ResultController.php index ab1759d..8698e19 100644 --- a/app/Http/Controllers/ResultController.php +++ b/app/Http/Controllers/ResultController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Events\ResultChanged; +use App\Models\DiscordBotCommand; use App\Models\Participant; use App\Models\Protocol; use App\Models\Result; @@ -50,6 +51,7 @@ class ResultController extends Controller $result, $request->user(), ); + DiscordBotCommand::queueResult($result); } else if ($result->wasChanged('comment')) { Protocol::resultCommented( $round->tournament, diff --git a/app/Models/DiscordBotCommand.php b/app/Models/DiscordBotCommand.php index 8a74d43..ca8a030 100644 --- a/app/Models/DiscordBotCommand.php +++ b/app/Models/DiscordBotCommand.php @@ -13,6 +13,18 @@ class DiscordBotCommand extends Model { use HasFactory; + public static function queueResult(Result $result) { + $cmd = new DiscordBotCommand(); + $cmd->tournament_id = $result->round->tournament_id; + $cmd->command = 'result'; + $cmd->parameters = [ + 'round' => $result->round_id, + 'user' => $result->user_id, + ]; + $cmd->status = 'pending'; + $cmd->save(); + } + public function tournament() { return $this->belongsTo(Tournament::class); }