-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
37 lines (31 loc) · 1.13 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
35
36
<?php
require "./bootstrap.php";
use App\Commands\Slash\Game;
use App\Responses\DefaultResponse;
use App\Services\Response\ResponseService;
use Discord\Discord;
use Discord\Exceptions\IntentException;
use Discord\Parts\Interactions\Interaction;
use Discord\Slash\RegisterClient;
use Discord\WebSockets\Event;
use Monolog\Logger;
try {
$discord = new Discord([
'token' => $_ENV['BOT_TOKEN'],
'logger' => new Logger('New logger'),
]);
$client = new RegisterClient($_ENV['BOT_TOKEN']);
$discord->on('ready', function (Discord $discord) {
$discord->on(Event::INTERACTION_CREATE, function (Interaction $interaction, Discord $discord) {
match (true) {
$interaction->data->name == "game" => new Game($interaction, $discord),
default => $interaction->respondWithMessage((new ResponseService)->run(DefaultResponse::definition()))
};
});
});
$discord->run();
} catch (IntentException|GuzzleHttp\Exception\ClientException|ArgumentCountError $e) {
var_dump($e->getMessage());
} catch (Exception $exception) {
var_dump($exception->getMessage());
}