]> git.localhorst.tv Git - alttp.git/commitdiff
dispatch discord command on result report
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 1 May 2022 13:14:54 +0000 (15:14 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 1 May 2022 13:14:54 +0000 (15:14 +0200)
app/Http/Controllers/ResultController.php
app/Models/DiscordBotCommand.php

index ab1759d6faaf1bf97fb9c0d5d2c51014a8935d3a..8698e19838aef615ee45b3ec5f4579ba58bb88d1 100644 (file)
@@ -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,
index 8a74d4342e11046c7c56f5fd41ea38a43810e229..ca8a0308ce0d96d37cd3d902b827cef327bb0925 100644 (file)
@@ -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);
        }