|
5 | 5 | use Closure;
|
6 | 6 | use Exception;
|
7 | 7 | use Ourted\Interfaces\Channel;
|
| 8 | +use Ourted\Interfaces\Emoji; |
8 | 9 | use Ourted\Interfaces\Guild;
|
9 | 10 | use Ourted\Interfaces\Invite;
|
10 | 11 | use Ourted\Interfaces\Member;
|
| 12 | +use Ourted\Interfaces\Settings; |
11 | 13 | use Ourted\Interfaces\User;
|
12 | 14 | use Ourted\Interfaces\Webhook;
|
13 | 15 | use Ourted\Model\Channel\Embed;
|
14 | 16 | use Ourted\Utils\getaway;
|
15 | 17 | use Ourted\Utils\http;
|
16 |
| -use Ourted\Interfaces\Settings; |
17 | 18 | use Ratchet\Client\Connector;
|
18 | 19 | use Ratchet\Client\WebSocket;
|
19 | 20 | use Ratchet\RFC6455\Messaging\MessageInterface;
|
@@ -108,6 +109,8 @@ class Bot
|
108 | 109 | public $invite;
|
109 | 110 | /** @var Webhook */
|
110 | 111 | public $webhook;
|
| 112 | + /** @var Emoji */ |
| 113 | + public $emoji; |
111 | 114 | /**
|
112 | 115 | * @var mixed
|
113 | 116 | */
|
@@ -171,6 +174,7 @@ public function __construct($botToken, $botPrefix, $wssUrl = null)
|
171 | 174 | $this->channel = new Channel($this);
|
172 | 175 | $this->member = new Member($this);
|
173 | 176 | $this->invite = new Invite($this);
|
| 177 | + $this->emoji = new Emoji($this); |
174 | 178 | $this->guild = new Guild($this);
|
175 | 179 | $this->user = new User($this);
|
176 | 180 | $this->api = new http($this);
|
@@ -202,18 +206,20 @@ public function init()
|
202 | 206 |
|
203 | 207 |
|
204 | 208 | $conn->on('close', function ($code = null, $reason = null) use ($conn) {
|
205 |
| - echo "\nConnection closed ({$code} - {$reason})\n"; |
| 209 | + echo "\nConnection closed ({$code} ". $reason != null ? "- {$reason})\n" : "\n"; |
206 | 210 | if (!$this->reconnect) {
|
207 | 211 | die();
|
208 | 212 | } else {
|
209 |
| - $conn->send(json_encode([ |
210 |
| - "op" => 6, |
211 |
| - "d" => [ |
212 |
| - "token" => $this->getBot()->token, |
213 |
| - "session_id" => $this->getBot()->session_id, |
214 |
| - "seq" => 1337 |
215 |
| - ] |
216 |
| - ])); |
| 213 | + echo "We are begin of a rate limit, connect retrying after 60 seconds."; |
| 214 | + $this->loop->addTimer(60, function () use ($conn) { |
| 215 | + $conn->send(json_encode([ |
| 216 | + "op" => 6, |
| 217 | + "d" => [ |
| 218 | + "token" => $this->getBot()->token, |
| 219 | + "session_id" => $this->getBot()->session_id, |
| 220 | + "seq" => 1337 |
| 221 | + ] |
| 222 | + ]));}); |
217 | 223 | }
|
218 | 224 | });
|
219 | 225 |
|
@@ -272,10 +278,11 @@ public function addCommand($command_name, $function)
|
272 | 278 | $function($this, $command_name);
|
273 | 279 | }
|
274 | 280 |
|
275 |
| - public function getImageData($image_path){ |
276 |
| - if(!file_exists($image_path) || str_ends_with($image_path, ("png" || "jpg" || "jpeg" | "PNG" || "JPG" || "JPEG"))) return "Fail"; |
| 281 | + public function getImageData($image_path) |
| 282 | + { |
| 283 | + if (!file_exists($image_path) || str_ends_with($image_path, ("png" || "jpg" || "jpeg" | "PNG" || "JPG" || "JPEG"))) return "Fail"; |
277 | 284 | $imageData = base64_encode(file_get_contents($image_path));
|
278 |
| - return 'data: '.mime_content_type($image_path).';base64,'.$imageData; |
| 285 | + return 'data: ' . mime_content_type($image_path) . ';base64,' . $imageData; |
279 | 286 | }
|
280 | 287 |
|
281 | 288 | /**
|
|
0 commit comments