1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
require_once(__DIR__ . '/../../htdocs/config.inc'); |
4
|
|
|
require_once(LIB . 'Default/smr.inc'); |
5
|
|
|
require_once(TOOLS . 'discord/GameLink.inc'); |
6
|
|
|
require_once(TOOLS . 'discord/mysql_cleanup.php'); |
7
|
|
|
require_once(CONFIG . 'discord/config.specific.php'); |
8
|
|
|
|
9
|
|
|
error_reporting(E_ALL); |
10
|
|
|
|
11
|
|
|
function getCommandPrefix() : string { |
12
|
|
|
return defined('COMMAND_PREFIX') ? COMMAND_PREFIX : '.'; |
|
|
|
|
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
$discord = new Discord\DiscordCommandClient([ |
|
|
|
|
16
|
|
|
'token' => DISCORD_TOKEN, |
17
|
|
|
'prefix' => getCommandPrefix(), |
18
|
|
|
'description' => 'Your automated co-pilot in the Space Merchant Realms universe. Made with DiscordPHP ' . Discord\Discord::VERSION . '.', |
|
|
|
|
19
|
|
|
'discordOptions' => [ |
20
|
|
|
'loggerLevel' => defined('LOGGER_LEVEL') ? LOGGER_LEVEL : 'INFO', |
|
|
|
|
21
|
|
|
], |
22
|
|
|
]); |
23
|
|
|
|
24
|
|
|
// Set bot presence to "Listening to <help command>" |
25
|
|
|
$discord->on('ready', function($discord) { |
26
|
|
|
$activity = $discord->factory(Discord\Parts\User\Activity::class, [ |
|
|
|
|
27
|
|
|
'name' => getCommandPrefix() . 'help', |
28
|
|
|
'type' => Discord\Parts\User\Activity::TYPE_LISTENING, |
29
|
|
|
]); |
30
|
|
|
$discord->updatePresence($activity); |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
// Register commands |
34
|
|
|
require_once('commands/money.php'); |
35
|
|
|
require_once('commands/game.php'); |
36
|
|
|
require_once('commands/turns.php'); |
37
|
|
|
require_once('commands/invite.php'); |
38
|
|
|
require_once('commands/op.php'); |
39
|
|
|
require_once('commands/seed.php'); |
40
|
|
|
require_once('commands/seedlist.php'); |
41
|
|
|
require_once('commands/forces.php'); |
42
|
|
|
require_once('commands/8ball.php'); |
43
|
|
|
|
44
|
|
|
// Close the connection we may have opened during startup |
45
|
|
|
// to avoid a mysql timeout. |
46
|
|
|
$db = new SmrMySqlDatabase(); |
47
|
|
|
$db->close(); |
48
|
|
|
|
49
|
|
|
$discord->run(); |
50
|
|
|
|