From: Daniel Karbach Date: Wed, 13 Apr 2022 15:36:25 +0000 (+0200) Subject: be rude to DMs X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=3960ca694af45464a44e5a4a68ae67fc895050c0;p=alttp.git be rude to DMs --- diff --git a/app/Console/Commands/DiscordBotCommand.php b/app/Console/Commands/DiscordBotCommand.php index 7d51cb9..d2cc73e 100644 --- a/app/Console/Commands/DiscordBotCommand.php +++ b/app/Console/Commands/DiscordBotCommand.php @@ -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();