|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Sovereign\Plugins\onMessage; |
|
4
|
|
|
|
|
5
|
|
|
use DateTime; |
|
6
|
|
|
use Discord\Discord; |
|
7
|
|
|
use Discord\Parts\Channel\Message; |
|
8
|
|
|
use Monolog\Logger; |
|
9
|
|
|
use Sovereign\Lib\Config; |
|
|
|
|
|
|
10
|
|
|
use Sovereign\Lib\cURL; |
|
11
|
|
|
use Sovereign\Lib\Db; |
|
12
|
|
|
use Sovereign\Lib\Permissions; |
|
13
|
|
|
use Sovereign\Lib\ServerConfig; |
|
14
|
|
|
use Sovereign\Lib\Settings; |
|
15
|
|
|
use Sovereign\Lib\Users; |
|
16
|
|
|
|
|
17
|
|
|
class about extends \Threaded implements \Collectable |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var Message |
|
21
|
|
|
*/ |
|
22
|
|
|
private $message; |
|
23
|
|
|
/** |
|
24
|
|
|
* @var Discord |
|
25
|
|
|
*/ |
|
26
|
|
|
private $discord; |
|
27
|
|
|
/** |
|
28
|
|
|
* @var Logger |
|
29
|
|
|
*/ |
|
30
|
|
|
private $log; |
|
31
|
|
|
/** |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
private $channelConfig; |
|
35
|
|
|
/** |
|
36
|
|
|
* @var Config |
|
37
|
|
|
*/ |
|
38
|
|
|
private $config; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var Db |
|
41
|
|
|
*/ |
|
42
|
|
|
private $db; |
|
43
|
|
|
/** |
|
44
|
|
|
* @var cURL |
|
45
|
|
|
*/ |
|
46
|
|
|
private $curl; |
|
47
|
|
|
/** |
|
48
|
|
|
* @var Settings |
|
49
|
|
|
*/ |
|
50
|
|
|
private $settings; |
|
51
|
|
|
/** |
|
52
|
|
|
* @var Permissions |
|
53
|
|
|
*/ |
|
54
|
|
|
private $permissions; |
|
55
|
|
|
/** |
|
56
|
|
|
* @var ServerConfig |
|
57
|
|
|
*/ |
|
58
|
|
|
private $serverConfig; |
|
59
|
|
|
/** |
|
60
|
|
|
* @var Users |
|
61
|
|
|
*/ |
|
62
|
|
|
private $users; |
|
63
|
|
|
/** |
|
64
|
|
|
* @var array |
|
65
|
|
|
*/ |
|
66
|
|
|
private $extras; |
|
67
|
|
|
|
|
68
|
|
View Code Duplication |
public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras) |
|
|
|
|
|
|
69
|
|
|
{ |
|
70
|
|
|
$this->message = $message; |
|
71
|
|
|
$this->discord = $discord; |
|
72
|
|
|
$this->channelConfig = $channelConfig; |
|
73
|
|
|
$this->log = $log; |
|
74
|
|
|
$this->config = $config; |
|
75
|
|
|
$this->db = $db; |
|
76
|
|
|
$this->curl = $curl; |
|
77
|
|
|
$this->settings = $settings; |
|
78
|
|
|
$this->permissions = $permissions; |
|
79
|
|
|
$this->serverConfig = $serverConfig; |
|
80
|
|
|
$this->users = $users; |
|
81
|
|
|
$this->extras = $extras; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function run() |
|
85
|
|
|
{ |
|
86
|
|
|
$time1 = new DateTime(date("Y-m-d H:i:s", $this->extras["startTime"])); |
|
87
|
|
|
$time2 = new DateTime(date("Y-m-d H:i:s")); |
|
88
|
|
|
$interval = $time1->diff($time2); |
|
89
|
|
|
|
|
90
|
|
|
$msg = "```I am the vanguard of your destruction. This exchange is just beginning... |
|
91
|
|
|
|
|
92
|
|
|
Author: Karbowiak (Discord ID: 118440839776174081) |
|
93
|
|
|
Library: DiscordPHP (https://github.com/teamreflex/DiscordPHP\) |
|
94
|
|
|
Current Version: 0.0000000000 |
|
95
|
|
|
Github Repo: https://github.com/karbowiak/Sovereign\ |
|
96
|
|
|
|
|
97
|
|
|
Statistics: |
|
98
|
|
|
Guild/Server Count: {$this->extras["guildCount"]} (For specifics use {$this->channelConfig->prefix}guilds) |
|
99
|
|
|
Member Count: {$this->extras["memberCount"]} |
|
100
|
|
|
Memory Usage: ~" . round(memory_get_usage() / 1024 / 1024, 3) . "MB |
|
101
|
|
|
Uptime: " . $interval->y . " Year(s), " . $interval->m . " Month(s), " . $interval->d . " Days, " . $interval->h . " Hours, " . $interval->i . " Minutes, " . $interval->s . " seconds. |
|
102
|
|
|
```"; |
|
103
|
|
|
$this->message->reply($msg); |
|
104
|
|
|
|
|
105
|
|
|
// Mark this as garbage |
|
106
|
|
|
$this->isGarbage(); |
|
107
|
|
|
} |
|
108
|
|
|
} |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: