Skip to content

Commit

Permalink
Merge pull request #1170 from discord-php/release-10-rc7
Browse files Browse the repository at this point in the history
Release 10 rc6
  • Loading branch information
SQKo authored Aug 13, 2023
2 parents da686d2 + 0462d49 commit fdfe82e
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 46 deletions.
6 changes: 3 additions & 3 deletions src/Discord/CommandClient/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ public function getCommand(string $command, bool $aliases = true): ?Command
/**
* Registers a new command.
*
* @param string $command The command name.
* @param callable|string $callable The function called when the command is executed.
* @param array $options An array of options.
* @param string $command The command name.
* @param callable|string $callable The function called when the command is executed.
* @param array $options An array of options.
*
* @return Command The command instance.
* @throws \Exception
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ protected function ready()

/* deprecated */
if ($this->listeners['ready']) {
if (count($this->listeners['ready'] ?? []) > 1 || count($this->onceListeners["ready"] ?? []) > 1) {
if (count($this->listeners['ready'] ?? []) > 1 || count($this->onceListeners['ready'] ?? []) > 1) {
$this->logger->info('The \'ready\' event is deprecated and will be removed in a future version of DiscordPHP. Please use \'init\' instead.');
}

Expand Down
12 changes: 6 additions & 6 deletions src/Discord/DiscordCommandClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ protected function checkForPrefix(string $content): ?string
/**
* Registers a new command.
*
* @param string $command The command name.
* @param callable|string $callable The function called when the command is executed.
* @param array $options An array of options.
* @param string $command The command name.
* @param callable|string $callable The function called when the command is executed.
* @param array $options An array of options.
*
* @return Command The command instance.
* @throws \Exception
Expand Down Expand Up @@ -325,9 +325,9 @@ public function getCommand(string $command, bool $aliases = true): ?Command
/**
* Builds a command and returns it.
*
* @param string $command The command name.
* @param callable|string $callable The function called when the command is executed.
* @param array $options An array of options.
* @param string $command The command name.
* @param callable|string $callable The function called when the command is executed.
* @param array $options An array of options.
*
* @return Command[]|array[] The command instance and options.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Discord/Parts/Channel/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ public function sendMessage($message, bool $tts = false, $embed = null, $allowed
$messagePart = $this->messages->create($response, true);
}

return $messagePart;
return $messagePart;
});
}

Expand Down Expand Up @@ -1365,7 +1365,7 @@ public function isTextBased()
self::TYPE_PUBLIC_THREAD,
self::TYPE_PRIVATE_THREAD,
self::TYPE_GUILD_ANNOUNCEMENT,
self::TYPE_GUILD_STAGE_VOICE
self::TYPE_GUILD_STAGE_VOICE,
]);
}

Expand Down
14 changes: 6 additions & 8 deletions src/Discord/Parts/Embed/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ public function setAuthor(string $name, $iconurl = null, ?string $url = null): s
/**
* Set the footer of this embed.
*
* @param string $text Maximum length is 2048 characters.
* @param string|Attachment|null $iconurl The URL to the icon, only http(s) and attachments URLs are allowed.
*
* @param string $text Maximum length is 2048 characters.
* @param string|Attachment|null $iconurl The URL to the icon, only http(s) and attachments URLs are allowed.
*
* @throws \LengthException Embed text too long.
* @throws \InvalidArgumentException Invalid scheme provided.
*
Expand Down Expand Up @@ -420,7 +420,6 @@ public function setFooter(string $text, $iconurl = null): self
'icon_url' => $iconurl,
];


return $this;
}

Expand All @@ -430,7 +429,7 @@ public function setFooter(string $text, $iconurl = null): self
* @param string|Attachment|null $url The URL to the image, only http(s) and attachments URLs are allowed.
*
* @throws \InvalidArgumentException Invalid scheme provided.
*
*
* @return $this
*/
public function setImage($url): self
Expand All @@ -452,7 +451,7 @@ public function setImage($url): self
* @param string|Attachment|null $url The URL to the thumbnail, only http(s) and attachments URLs are allowed.
*
* @throws \InvalidArgumentException Invalid scheme provided.
*
*
* @return $this
*/
public function setThumbnail($url): self
Expand Down Expand Up @@ -503,11 +502,10 @@ public function setURL(string $url): self
*
* @param ?string $url
*
* @return void
*
* @throws \DomainException
*/
function ensureValidUrl(?string $url = null, array $allowed = ['http', 'https', 'attachment'])
protected function ensureValidUrl(?string $url = null, array $allowed = ['http', 'https', 'attachment'])
{
if (null !== $url && ! in_array(parse_url($url, PHP_URL_SCHEME), $allowed)) {
throw new \DomainException('Url scheme only supports '.implode(', ', $allowed));
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/Guild/AutoModeration/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Action extends Part
public const TYPE_TIMEOUT = 3;

/**
* Get the Metadata Attributes
* Get the Metadata Attributes.
*
* @return ?ActionMetadata
*/
Expand Down
12 changes: 5 additions & 7 deletions src/Discord/Parts/Interactions/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,12 @@ protected function getChannelAttribute(): ?Part
if (
! in_array($this->attributes['channel']->type ?? null, [Channel::TYPE_PUBLIC_THREAD, CHANNEL::TYPE_PRIVATE_THREAD, CHANNEL::TYPE_ANNOUNCEMENT_THREAD])
&& $channel = $channels->get('id', $channelId)
)
{
) {
return $channel;
} else {
foreach ($channels as $parent) {
if ($thread = $parent->threads->get('id', $channelId)) {
return $thread;
}
}
foreach ($channels as $parent) {
if ($thread = $parent->threads->get('id', $channelId)) {
return $thread;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/Permissions/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract class Permission extends Part
/**
* Array of permissions that only apply to text channels.
* i.e. indicated T in documentation.
*
*
* The constant values here are the bit position, not the bitwise value
*
* @see ChannelPermission
Expand Down
5 changes: 2 additions & 3 deletions src/Discord/Parts/Thread/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use function Discord\getSnowflakeTimestamp;
use function React\Promise\all;
use function React\Promise\reject;
use function React\Promise\resolve;

/**
* Represents a Discord thread.
Expand Down Expand Up @@ -722,7 +721,7 @@ public function sendMessage($message, bool $tts = false, $embed = null, $allowed

return $this->http->post(Endpoint::bind(Endpoint::CHANNEL_MESSAGES, $this->id), $message);
})()->then(function ($response) {
return $this->messages->get('id', $response->id) ?: $this->messages->create($response, true);
return $this->messages->get('id', $response->id) ?: $this->messages->create($response, true);
});
}

Expand Down Expand Up @@ -845,7 +844,7 @@ public function getCreatableAttributes(): array

if ($this->type == Channel::TYPE_PRIVATE_THREAD) {
$attr += $this->makeOptionalAttributes([
'invitable' => $this->invitable
'invitable' => $this->invitable,
]);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Discord/Parts/User/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ public function timeoutMember(?Carbon $communication_disabled_until, ?string $re
/**
* Sets verification bypasses flag on a member.
*
* @param bool $bypasses_verification Whether member is exempt from guild verification requirements.
* @param string|null $reason Reason for Audit Log.
* @param bool $bypasses_verification Whether member is exempt from guild verification requirements.
* @param string|null $reason Reason for Audit Log.
*
* @throws NoPermissionsException Missing `moderate_members` permission.
*
Expand Down Expand Up @@ -576,7 +576,7 @@ public function setBypassesVerification(bool $bypasses_verification, ?string $re
$flags &= ~self::FLAGS_BYPASSES_VERIFICATION;
}

return $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER, $this->guild_id, $this->id), ['flags' => $flags ], $headers)
return $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER, $this->guild_id, $this->id), ['flags' => $flags], $headers)
->then(function ($response) {
$this->attributes['flags'] = $response->flags;

Expand All @@ -593,7 +593,7 @@ protected function getDisplaynameAttribute(): string
{
$user = $this->user;

return ($this->nick ?? $user->global_name ?? $user->username) . ($user->discriminator ? '#' . $user->discriminator : '');
return ($this->nick ?? $user->global_name ?? $user->username).($user->discriminator ? '#'.$user->discriminator : '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/WebSockets/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ abstract class Event
public const AUTO_MODERATION_RULE_DELETE = 'AUTO_MODERATION_RULE_DELETE';
public const AUTO_MODERATION_ACTION_EXECUTION = 'AUTO_MODERATION_ACTION_EXECUTION';

public const GUILD_AUDIT_LOG_ENTRY_CREATE ='GUILD_AUDIT_LOG_ENTRY_CREATE';
public const GUILD_AUDIT_LOG_ENTRY_CREATE = 'GUILD_AUDIT_LOG_ENTRY_CREATE';

// Channel
public const CHANNEL_CREATE = 'CHANNEL_CREATE';
Expand Down
6 changes: 4 additions & 2 deletions src/Discord/WebSockets/Events/GuildCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ public function handle($data)
});

if (
($this->discord->options['retrieveBans'] === true
|| (is_array($this->discord->options['retrieveBans'])
(
$this->discord->options['retrieveBans'] === true
|| (
is_array($this->discord->options['retrieveBans'])
&& in_array($data->id, $this->discord->options['retrieveBans'])
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/WebSockets/Intents.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Intents
* Guild moderation events.
* - GUILD_AUDIT_LOG_ENTRY_CREATE
* - GUILD_BAN_ADD
* - GUILD_BAN_REMOVE
* - GUILD_BAN_REMOVE.
*/
public const GUILD_MODERATION = (1 << 2);

Expand Down
2 changes: 1 addition & 1 deletion src/Discord/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function nowait(PromiseInterface $promiseInterface)
}

/**
* File namespaces that were changed in new versions are aliased
* File namespaces that were changed in new versions are aliased.
*/
class_alias(\Discord\Repository\Channel\StageInstanceRepository::class, '\Discord\Repository\Guild\StageInstanceRepository'); // @since 10.0.0
class_alias(\Discord\Parts\Guild\CommandPermissions::class, '\Discord\Parts\Interactions\Command\Overwrite'); // @since 10.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function testNormalizePartId($part, $expected): void
$expected,
(normalizePartId())(
new OptionsResolver(),
$part
$part
)
);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Parts/Channel/Message/EmbedMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public function testCanSendEmbed()
$this->assertEquals('Footer Value', $embed->footer->text);

$this->assertEquals(2, $embed->fields->count());
$this->assertNotFalse(isset($embed->fields['Field 1']));
$this->assertNotFalse(isset($embed->fields['Field 2']));
$this->assertNotNull($embed->fields->get('name', 'Field 1'));
$this->assertNotNull($embed->fields->get('name', 'Field 2'));

$this->assertNotEquals(
(string) $embed->fields['Field 1'],
(string) $embed->fields['Field 2']
(string) $embed->fields->get('name', 'Field 1'),
(string) $embed->fields->get('name', 'Field 2')
);
})
->done($resolve, $resolve);
Expand Down

0 comments on commit fdfe82e

Please sign in to comment.