]> git.localhorst.tv Git - alttp.git/blob - app/DiscordBotCommands/PresenceCommand.php
better chat filters
[alttp.git] / app / DiscordBotCommands / PresenceCommand.php
1 <?php
2
3 namespace App\DiscordBotCommands;
4
5 use App\Models\DiscordBotCommand;
6 use Discord\Discord;
7 use Discord\Parts\User\Activity;
8 use React\Promise\Promise;
9
10 class PresenceCommand extends BaseCommand {
11
12         public function __construct(Discord $discord, DiscordBotCommand $cmd) {
13                 parent::__construct($discord, $cmd);
14         }
15
16         public function execute() {
17                 return new Promise(function($resolve) {
18                         $activity = null;
19                         $idle = false;
20                         $status = 'online';
21                         $afk = false;
22                         if ($this->hasParameter('activity')) {
23                                 $activity = new Activity($this->discord);
24                                 $activity->type = $this->getParameter('activity');
25                                 if ($this->hasParameter('name')) {
26                                         $activity->name = $this->getParameter('name');
27                                 }
28                                 if ($this->hasParameter('url')) {
29                                         $activity->url = $this->getParameter('url');
30                                 }
31                         }
32                         if ($this->hasParameter('idle')) {
33                                 $idle = $this->parameters['idle'];
34                         }
35                         if ($this->hasParameter('status')) {
36                                 $status = $this->getParameter('status');
37                         }
38                         if ($this->hasParameter('afk')) {
39                                 $afk = $this->getParameter('afk');
40                         }
41                         $this->discord->updatePresence($activity, $idle, $status, $afk);
42                         $resolve();
43                 });
44         }
45
46 }