/dreamers invite command

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2023-12-31 17:09:20 +07:00
parent 611c2f52df
commit 2dcf4adc33

View File

@ -11,9 +11,14 @@ use mirzaev\marina\controllers\core;
use Discord\Discord as discord, use Discord\Discord as discord,
Discord\Parts\Channel\Message as message, Discord\Parts\Channel\Message as message,
Discord\Parts\Guild\Role as role, Discord\Parts\Guild\Role as role,
Discord\Parts\Guild\CommandPermissions as permissions,
Discord\Parts\User\Member as member, Discord\Parts\User\Member as member,
Discord\Parts\Interactions\Interaction as interaction,
Discord\WebSockets\Event as event, 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; use exception;
@ -41,10 +46,8 @@ final class index extends core
// Сообщение: "марина" // Сообщение: "марина"
$discord->on(event::MESSAGE_CREATE, function (message $message, discord $discord) { $discord->on(event::MESSAGE_CREATE, function (message $message, discord $discord) {
if ($message->author->bot) { // Игнорирование чат-роботов
// Do nothing if ($message->author->bot) return;
return;
}
// Запись в буфер вывода (терминал) // Запись в буфер вывода (терминал)
echo "{$message->author->username}: {$message->content}", PHP_EOL; 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(); $this->discord->run();