-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·34 lines (28 loc) · 1.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
include __DIR__.'/core/bootstrap.php';
use App\Exception\ExceptionHandler;
use App\Exception\ShouldReturnCommandHelpResponseInterface;
use App\Response\CommandHelpResponse;
use App\Service\Command\HandleCommandService;
use Discord\Discord;
use Discord\Parts\Channel\Message;
use Discord\WebSockets\Event;
$discord = discordApp();
$discord->on('ready', function ($discord) {
echo "Bot is ready!", PHP_EOL;
$discord->on(Event::MESSAGE_CREATE, function (Message $message, $discord) {
$exceptionHandler = new ExceptionHandler();
if (str_starts_with($message->content, '#')) {
try {
$handleMessageService = new HandleCommandService($message);
$handleMessageService->handle();
} catch (Throwable $exception) {
$exceptionHandler->handle($exception, $message->content);
if ($exception instanceof ShouldReturnCommandHelpResponseInterface) {
return new CommandHelpResponse($message);
}
}
}
});
});
$discord->run();