-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.php
52 lines (37 loc) · 1.14 KB
/
run.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include __DIR__.'/vendor/autoload.php';
date_default_timezone_set('Asia/Jakarta');
use Discord\DiscordCommandClient;
$token = 'Njk4NDI0ODc3MjA3NjUwMzQ0.XpGadQ.7V64GDabo7uCSpEvvgsGWWM6tHA';
$discord = new DiscordCommandClient([
'token' => $token,
'prefix' => '#',
'name' => 'COV19D',
'description' => 'The latest information about COVID19 | Contact : eggyaprilianto@gmail.com',
]);
$discord->on('ready', function ($discord) {
echo "Bot is ready.", PHP_EOL;
// Listen for events here
$discord->on('message', function ($message) {
echo "Recieved a message from {$message->author->username}: {$message->content}", PHP_EOL;
});
});
$discord->registerCommand('info', function($message)
{
$get = file_get_contents("https://api.kawalcorona.com/indonesia");
$hasil = json_decode($get);
$pesan =
"
```
Cek Kasus Covid19 Di Indonesia | COV19D
Positif : ".$hasil[0]->positif."
Sembuh : ".$hasil[0]->sembuh."
Meninggal : ".$hasil[0]->meninggal."
Last update : ".date('d M Y H:i:s')."
```
";
$message->channel->sendMessage($pesan);
}, [
'description' => 'Cek kasus covid19 hari ini.',
]);
$discord->run();