Skip to content

Commit ceab544

Browse files
authored
v3.0.3
Merge pull request #112 from DiscordBot-PMMP/development
2 parents 819a61d + bada2a3 commit ceab544

File tree

5 files changed

+24
-47
lines changed

5 files changed

+24
-47
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [3.0.3] - 2023-10-19
4+
5+
### Fixed
6+
7+
- Fix external client not closing socket correctly ([`029c621`](https://github.com/DiscordBot-PMMP/DiscordBot/commit/029c621b26fd919479e144784dca56efa980367f))
8+
9+
### Removed
10+
11+
- Removed hardcoded guild features list & assertions ([#111](https://github.com/DiscordBot-PMMP/DiscordBot/issues/111))
12+
313
## [3.0.2] - 2023-09-04
414

515
### Changed
@@ -215,6 +225,7 @@ _**Breaking:** Plugin re-released as a central API._
215225

216226
_This release was never published to public._
217227

228+
[3.0.3]: https://github.com/DiscordBot-PMMP/DiscordBot/releases/tag/3.0.3
218229
[3.0.2]: https://github.com/DiscordBot-PMMP/DiscordBot/releases/tag/3.0.2
219230
[3.0.1]: https://github.com/DiscordBot-PMMP/DiscordBot/releases/tag/3.0.1
220231
[3.0.0]: https://github.com/DiscordBot-PMMP/DiscordBot/releases/tag/3.0.0

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: DiscordBot
2-
version: 3.0.2
2+
version: 3.0.3
33
author: JaxkDev
44
src-namespace-prefix: JaxkDev\DiscordBot
55
main: JaxkDev\DiscordBot\Plugin\Main

src/Communication/Thread.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ public function run(): void{
4848
// Note, this does not affect outside thread.
4949
ini_set("date.timezone", "UTC");
5050

51-
if($this->config["type"] === "internal"){
52-
new InternalClient($this);
53-
}else{
54-
new ExternalClient($this);
51+
try{
52+
if($this->config["type"] === "internal"){
53+
new InternalClient($this);
54+
}else{
55+
new ExternalClient($this);
56+
}
57+
}catch(\Throwable){
58+
$this->setStatus(ThreadStatus::STOPPED);
59+
exit(1);
5560
}
5661
}
5762

src/ExternalBot/Socket/Socket.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function open(): void{
7070
public function close(string $reason = "Unknown"): void{
7171
if(!$this->open){
7272
$this->logger->warning("Cannot close a non-open socket.");
73+
return;
7374
}
7475
@socket_close($this->socket);
7576
$this->open = false;

src/Models/Guild/Guild.php

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use JaxkDev\DiscordBot\Models\Emoji;
1818
use JaxkDev\DiscordBot\Models\Sticker;
1919
use JaxkDev\DiscordBot\Plugin\Utils;
20-
use function in_array;
2120

2221
/**
2322
* @implements BinarySerializable<Guild>
@@ -40,40 +39,6 @@ final class Guild implements BinarySerializable{
4039
"SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES" => (1 << 5)
4140
];
4241

43-
/**
44-
* @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
45-
* @var string[]
46-
*/
47-
public const FEATURES = [
48-
"ANIMATED_BANNER",
49-
"ANIMATED_ICON",
50-
"APPLICATION_COMMAND_PERMISSIONS_V2",
51-
"AUTO_MODERATION",
52-
"BANNER",
53-
"COMMUNITY",
54-
"CREATOR_MONETIZABLE_PROVISIONAL",
55-
"CREATOR_STORE_PAGE",
56-
"DEVELOPER_SUPPORT_SERVER",
57-
"DISCOVERABLE",
58-
"FEATURABLE",
59-
"INVITES_DISABLED",
60-
"INVITE_SPLASH",
61-
"MEMBER_VERIFICATION_GATE_ENABLED",
62-
"MORE_STICKERS",
63-
"NEWS",
64-
"PARTNERED",
65-
"PREVIEW_ENABLED",
66-
"RAID_ALERTS_DISABLED",
67-
"ROLE_ICONS",
68-
"ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE",
69-
"ROLE_SUBSCRIPTIONS_ENABLED",
70-
"TICKETED_EVENTS_ENABLED",
71-
"VANITY_URL",
72-
"VERIFIED",
73-
"VIP_REGIONS",
74-
"WELCOME_SCREEN_ENABLED"
75-
];
76-
7742
/** Guild id */
7843
private string $id;
7944

@@ -120,7 +85,7 @@ final class Guild implements BinarySerializable{
12085
private array $emojis;
12186

12287
/**
123-
* @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
88+
* @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features - NOTE, Does not contain all features.
12489
* @var string[]
12590
*/
12691
private array $features;
@@ -176,7 +141,7 @@ final class Guild implements BinarySerializable{
176141
/** The NSFW level of the guild */
177142
private NsfwLevel $nsfw_level;
178143

179-
/*
144+
/**
180145
* Custom guild stickers
181146
* @var Sticker[]
182147
*/
@@ -395,11 +360,6 @@ public function getFeatures(): array{
395360

396361
/** @param string[] $features */
397362
public function setFeatures(array $features): void{
398-
foreach($features as $feature){
399-
if(!in_array($feature, self::FEATURES, true)){
400-
throw new \AssertionError("Feature '$feature' is invalid.");
401-
}
402-
}
403363
$this->features = $features;
404364
}
405365

0 commit comments

Comments
 (0)