]> git.localhorst.tv Git - alttp.git/commitdiff
less verbose discord bot logger
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 13 Apr 2022 13:40:03 +0000 (15:40 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 13 Apr 2022 13:40:03 +0000 (15:40 +0200)
app/Console/Commands/DiscordBotCommand.php [new file with mode: 0644]
app/Console/Commands/DiscortBotCommand.php [deleted file]

diff --git a/app/Console/Commands/DiscordBotCommand.php b/app/Console/Commands/DiscordBotCommand.php
new file mode 100644 (file)
index 0000000..7d51cb9
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Discord\Discord;
+use Illuminate\Console\Command;
+use Monolog\Handler\StreamHandler;
+use Monolog\Logger;
+use React\EventLoop\Loop;
+
+class DiscordBotCommand extends Command
+{
+       /**
+        * The name and signature of the console command.
+        *
+        * @var string
+        */
+       protected $signature = 'discord:bot';
+
+       /**
+        * The console command description.
+        *
+        * @var string
+        */
+       protected $description = 'Runs the discord bot';
+
+       /**
+        * Execute the console command.
+        *
+        * @return int
+        */
+       public function handle()
+       {
+               $logger = new Logger('DiscordBot');
+               $logger->pushHandler(new StreamHandler('php://stdout', Logger::INFO));
+               $discord = new Discord([
+                       'logger' => $logger,
+                       'token' => config('discord.token'),
+               ]);
+               $discord->on('ready', function (Discord $discord) {
+               });
+               $discord->getLoop()->addSignal(SIGINT, function() use ($discord) {
+                       $discord->close();
+               });
+               $discord->run();
+               return 0;
+       }
+}
diff --git a/app/Console/Commands/DiscortBotCommand.php b/app/Console/Commands/DiscortBotCommand.php
deleted file mode 100644 (file)
index f400baa..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use Discord\Discord;
-use Illuminate\Console\Command;
-use React\EventLoop\Loop;
-
-class DiscortBotCommand extends Command
-{
-       /**
-        * The name and signature of the console command.
-        *
-        * @var string
-        */
-       protected $signature = 'discord:bot';
-
-       /**
-        * The console command description.
-        *
-        * @var string
-        */
-       protected $description = 'Runs the discord bot';
-
-       /**
-        * Execute the console command.
-        *
-        * @return int
-        */
-       public function handle()
-       {
-               $discord = new Discord([
-                       'token' => config('discord.token'),
-               ]);
-               $discord->on('ready', function (Discord $discord) {
-               });
-               $discord->getLoop()->addSignal(SIGINT, function() use ($discord) {
-                       $discord->close();
-               });
-               $discord->run();
-               return 0;
-       }
-}