]> git.localhorst.tv Git - alttp.git/commitdiff
be rude to DMs
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 13 Apr 2022 15:36:25 +0000 (17:36 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 13 Apr 2022 15:36:25 +0000 (17:36 +0200)
app/Console/Commands/DiscordBotCommand.php

index 7d51cb9df4868ec0bc76fcfc22c13d28a66606a0..d2cc73e4def81fab37d50188c1d0cee3c7cf6237 100644 (file)
@@ -3,6 +3,8 @@
 namespace App\Console\Commands;
 
 use Discord\Discord;
+use Discord\Parts\Channel\Message;
+use Discord\WebSockets\Event;
 use Illuminate\Console\Command;
 use Monolog\Handler\StreamHandler;
 use Monolog\Logger;
@@ -38,6 +40,23 @@ class DiscordBotCommand extends Command
                        'token' => config('discord.token'),
                ]);
                $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();