From 2dcf4adc33778d68de657d3f1e0d9f1a10e0e0b6 Mon Sep 17 00:00:00 2001 From: mirzaev Date: Sun, 31 Dec 2023 17:09:20 +0700 Subject: [PATCH] /dreamers invite command --- mirzaev/marina/system/controllers/index.php | 30 +++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/mirzaev/marina/system/controllers/index.php b/mirzaev/marina/system/controllers/index.php index 02e0d77..5abd181 100644 --- a/mirzaev/marina/system/controllers/index.php +++ b/mirzaev/marina/system/controllers/index.php @@ -11,9 +11,14 @@ use mirzaev\marina\controllers\core; use Discord\Discord as discord, Discord\Parts\Channel\Message as message, Discord\Parts\Guild\Role as role, + Discord\Parts\Guild\CommandPermissions as permissions, Discord\Parts\User\Member as member, + Discord\Parts\Interactions\Interaction as interaction, Discord\WebSockets\Event as event, - Discord\Builders\MessageBuilder as _message; + Discord\Parts\Interactions\Command\Command as command, + Discord\Builders\MessageBuilder as _message, + Discord\Builders\CommandBuilder as _command, + Discord\Parts\Interactions\Command\Option as option; // Встроенные библиотеки use exception; @@ -41,10 +46,8 @@ final class index extends core // Сообщение: "марина" $discord->on(event::MESSAGE_CREATE, function (message $message, discord $discord) { - if ($message->author->bot) { - // Do nothing - return; - } + // Игнорирование чат-роботов + if ($message->author->bot) return; // Запись в буфер вывода (терминал) echo "{$message->author->username}: {$message->content}", PHP_EOL; @@ -196,6 +199,23 @@ final class index extends core * */ }); + + $discord->application->commands->save(new command($discord, [ + 'name' => 'dreamers', + 'description' => 'BEBRA DREAMERS', + 'options' => [(new option($discord)) + ->setName('invite') + ->setDescription('Send an invitation link to "BEBRA DREAMERS"') + ->setType(option::SUB_COMMAND)] + ])); + + $discord->listenCommand(['dreamers', 'invite'], function (interaction $interaction) { + // Игнорирование чат-роботов + if ($interaction->user->bot) return; + + // Отправка ссылки с приглашением присоединиться на сервер BEBRA DREAMERS + if ($interaction->data->options->has('invite')) $interaction->respondWithMessage(_message::new()->setContent('https://discord.bebra.team')); + }); }); $this->discord->run();