]> git.localhorst.tv Git - alttp.git/blob - app/Console/Commands/DiscortBotCommand.php
f400baac6d14338a45d8d7fda4a865069ec73014
[alttp.git] / app / Console / Commands / DiscortBotCommand.php
1 <?php
2
3 namespace App\Console\Commands;
4
5 use Discord\Discord;
6 use Illuminate\Console\Command;
7 use React\EventLoop\Loop;
8
9 class DiscortBotCommand extends Command
10 {
11         /**
12          * The name and signature of the console command.
13          *
14          * @var string
15          */
16         protected $signature = 'discord:bot';
17
18         /**
19          * The console command description.
20          *
21          * @var string
22          */
23         protected $description = 'Runs the discord bot';
24
25         /**
26          * Execute the console command.
27          *
28          * @return int
29          */
30         public function handle()
31         {
32                 $discord = new Discord([
33                         'token' => config('discord.token'),
34                 ]);
35                 $discord->on('ready', function (Discord $discord) {
36                 });
37                 $discord->getLoop()->addSignal(SIGINT, function() use ($discord) {
38                         $discord->close();
39                 });
40                 $discord->run();
41                 return 0;
42         }
43 }