]> git.localhorst.tv Git - alttp.git/blobdiff - app/Console/Commands/DiscordBotCommand.php
remove discord bot auto response
[alttp.git] / app / Console / Commands / DiscordBotCommand.php
index 7d9b65e6e358401e2880d4c2a80788a3bec8b6f4..066f5ff51920027f5b0f72b1bb609532d5bb484e 100644 (file)
@@ -2,9 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Models\DiscordChannel;
 use App\Models\DiscordGuild;
 use App\Models\DiscordRole;
 use Discord\Discord;
+use Discord\Parts\Channel\Channel;
 use Discord\Parts\Channel\Message;
 use Discord\Parts\Guild\Guild;
 use Discord\Parts\Guild\Role;
@@ -57,6 +59,27 @@ class DiscordBotCommand extends Command
                                $this->error('guild update: '.$e->getMessage());
                        }
                });
+               $discord->on(Event::CHANNEL_CREATE, function (Channel $channel, Discord $discord) {
+                       try {
+                               DiscordGuild::onUpstreamCreate($channel);
+                       } catch (\Exception $e) {
+                               $this->error('channel create: '.$e->getMessage());
+                       }
+               });
+               $discord->on(Event::CHANNEL_UPDATE, function (Channel $channel, Discord $discord, ?Channel $old) {
+                       try {
+                               DiscordGuild::onUpstreamUpdate($channel);
+                       } catch (\Exception $e) {
+                               $this->error('channel update: '.$e->getMessage());
+                       }
+               });
+               $discord->on(Event::CHANNEL_DELETE, function ($channel, Discord $discord) {
+                       try {
+                               DiscordGuild::onUpstreamDelete($channel);
+                       } catch (\Exception $e) {
+                               $this->error('channel delete: '.$e->getMessage());
+                       }
+               });
                $discord->on(Event::GUILD_ROLE_CREATE, function (Role $role, Discord $discord) {
                        try {
                                DiscordRole::onUpstreamCreate($role);
@@ -64,7 +87,7 @@ class DiscordBotCommand extends Command
                                $this->error('guild role create: '.$e->getMessage());
                        }
                });
-               $discord->on(Event::GUILD_ROLE_UPDATE, function (Role $role, Discord $discordi, ?Role $old) {
+               $discord->on(Event::GUILD_ROLE_UPDATE, function (Role $role, Discord $discord, ?Role $old) {
                        try {
                                DiscordRole::onUpstreamUpdate($role);
                        } catch (\Exception $e) {
@@ -78,25 +101,6 @@ class DiscordBotCommand extends Command
                                $this->error('guild role delete: '.$e->getMessage());
                        }
                });
-               $discord->on('ready', function (Discord $discord) {
-                       $discord->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
-                               if (!empty($message->guild_id)) return;
-                               if (!empty($message->webhook_id)) return;
-                               if (!empty($message->application_id)) return;
-                               if (is_null($message->author)) return;
-                               if ($message->author->bot) return;
-                               $discord->getLoop()->addTimer(0.6, function() use ($message) {
-                                       $message->react('😄');
-                               });
-                               if (!is_null($message->channel)) {
-                                       $discord->getLoop()->addTimer(2.0, function() use ($message) {
-                                               $message->channel->sendMessage('bugger off');
-                                       });
-                               } else {
-                                       $message->delayedReply('bugger off', 2000);
-                               }
-                       });
-               });
                $discord->getLoop()->addSignal(SIGINT, function() use ($discord) {
                        $discord->close();
                });