]> git.localhorst.tv Git - alttp.git/blobdiff - app/Console/Commands/DiscordBotCommand.php
discord bot presence command
[alttp.git] / app / Console / Commands / DiscordBotCommand.php
index c0a92b885867161acc1ed350574a5b32de070972..4368bb5b1d4b06d2bc815c74ff35d470cf708d95 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Models\DiscordBotCommand as CommandModel;
 use App\Models\DiscordChannel;
 use App\Models\DiscordGuild;
 use App\Models\DiscordRole;
@@ -52,6 +53,16 @@ class DiscordBotCommand extends Command
                        $activity->name = 'HolySmoke';
                        $activity->url = 'https://alttp.localhorst.tv/';
                        $discord->updatePresence($activity);
+
+                       $discord->getLoop()->addPeriodicTimer(1, function () use ($discord) {
+                               $command = CommandModel::where('status', '=', 'pending')->oldest()->first();
+                               if ($command) {
+                                       try {
+                                               $command->execute($discord);
+                                       } catch (\Exception $e) {
+                                       }
+                               }
+                       });
                });
                $discord->on(Event::GUILD_CREATE, function (Guild $guild, Discord $discord) {
                        try {