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;
'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();