From 4cab26d433ec16fa77373a82d1f8536250f762cd Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Sun, 19 May 2024 14:56:16 -0400 Subject: [PATCH 01/24] Add missing consts to Entry.php See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events --- src/Discord/Parts/Guild/AuditLog/Entry.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Discord/Parts/Guild/AuditLog/Entry.php b/src/Discord/Parts/Guild/AuditLog/Entry.php index 4061d8a20..70ccc9979 100644 --- a/src/Discord/Parts/Guild/AuditLog/Entry.php +++ b/src/Discord/Parts/Guild/AuditLog/Entry.php @@ -88,6 +88,8 @@ class Entry extends Part public const AUTO_MODERATION_BLOCK_MESSAGE = 143; public const AUTO_MODERATION_FLAG_TO_CHANNEL = 144; public const AUTO_MODERATION_USER_COMMUNICATION_DISABLED = 145; + public const CREATOR_MONETIZATION_REQUEST_CREATED = 150; + public const CREATOR_MONETIZATION_TERMS_ACCEPTED = 151; // AUDIT LOG ENTRY TYPES From 6c6b6fc2d659dbcd27bea416ce86612c6c0a2c23 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Mon, 17 Jun 2024 13:38:22 -0400 Subject: [PATCH 02/24] Fix typo: change < to << --- src/Discord/Parts/User/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Parts/User/User.php b/src/Discord/Parts/User/User.php index dbae2bea0..fe1339eb3 100644 --- a/src/Discord/Parts/User/User.php +++ b/src/Discord/Parts/User/User.php @@ -70,7 +70,7 @@ class User extends Part implements Stringable public const FLAG_VERIFIED_BOT_DEVELOPER = (1 << 17); public const FLAG_DISCORD_CERTIFIED_MODERATOR = (1 << 18); public const BOT_HTTP_INTERACTIONS = (1 << 19); - public const FLAG_ACTIVE_DEVELOPER = (1 < 22); + public const FLAG_ACTIVE_DEVELOPER = (1 << 22); public const PREMIUM_NONE = 0; public const PREMIUM_NITRO_CLASSIC = 1; From 4ce21441c268817fb7e61ed5ddedb3374ebdc7fe Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 18 Jul 2024 19:09:52 -0500 Subject: [PATCH 03/24] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Impro?= =?UTF-8?q?ve=20the=20command=20builder=20(#1243)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🧑‍💻 Add `guild_id` support to the command attributes * 🩹 Allow `null` descriptions on the command builder for context menus 🩹 Add missing `nsfw` attribute to the command builder 🔧 Add the `guild_id` attribute to the command builder --- src/Discord/Builders/CommandAttributes.php | 17 ++++++++++++++++- src/Discord/Builders/CommandBuilder.php | 6 ++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Discord/Builders/CommandAttributes.php b/src/Discord/Builders/CommandAttributes.php index ab321bfe6..877dca08f 100644 --- a/src/Discord/Builders/CommandAttributes.php +++ b/src/Discord/Builders/CommandAttributes.php @@ -27,12 +27,13 @@ * @property int $type The type of the command, defaults 1 if not set. * @property string $name 1-32 character name of the command. * @property ?string[]|null $name_localizations Localization dictionary for the name field. Values follow the same restrictions as name. - * @property string $description 1-100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands. + * @property ?string $description 1-100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands. * @property ?string[]|null $description_localizations Localization dictionary for the description field. Values follow the same restrictions as description. * @property \Discord\Helpers\Collection|Option[]|null $options The parameters for the command, max 25. Only for Slash command (CHAT_INPUT). * @property ?string $default_member_permissions Set of permissions represented as a bit set. * @property bool|null $dm_permission Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible. * @property ?bool $default_permission Whether the command is enabled by default when the app is added to a guild. SOON DEPRECATED. + * @property ?int $guild_id The optional guild ID this command is for. If not set, the command is global. * @property bool|null $nsfw Indicates whether the command is age-restricted, defaults to `false`. */ trait CommandAttributes @@ -208,6 +209,20 @@ public function setDmPermission(bool $permission): self return $this; } + /** + * Sets the guild ID of the command. + * + * @param int $guildId Guild ID of the command. + * + * @return $this + */ + public function setGuildId(int $guildId): self + { + $this->guild_id = $guildId; + + return $this; + } + /** * Sets the age restriction of the command. * diff --git a/src/Discord/Builders/CommandBuilder.php b/src/Discord/Builders/CommandBuilder.php index df463b29f..2b6ad54de 100644 --- a/src/Discord/Builders/CommandBuilder.php +++ b/src/Discord/Builders/CommandBuilder.php @@ -43,9 +43,9 @@ class CommandBuilder implements JsonSerializable /** * Description of the command. should be empty if the type is not CHAT_INPUT. * - * @var string + * @var string|null */ - protected string $description; + protected ?string $description = null; /** * The default permission of the command. If true the command is enabled when the app is added to the guild. @@ -96,6 +96,8 @@ public function toArray(): array 'default_member_permissions', 'default_permission', 'dm_permission', + 'guild_id', + 'nsfw', ]; foreach ($optionals as $optional) { From 943b498a7b72edec67d296570fc8d5e2e27b4682 Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Sun, 21 Jul 2024 14:24:13 +0200 Subject: [PATCH 04/24] Upgrade Carbon library (#1222) * Upgrade Carbon library * Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 03e116f39..2102074e3 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require": { "php": "^8.0", - "nesbot/carbon": "^2.38", + "nesbot/carbon": "^2.38 || ^3.0", "ratchet/pawl": "^0.4.1", "react/datagram": "^1.8", "symfony/options-resolver": "^5.1.11 || ^6.0 || ^7.0", From fe6c8f1aece0fccfc2dd8907231066d7c545ffe9 Mon Sep 17 00:00:00 2001 From: Steffen Weber Date: Fri, 12 Jul 2024 11:30:31 +0200 Subject: [PATCH 05/24] Fix Discord\Parts\Channel\Channel::sendMessage PHPDoc type hint Otherwise PHPStan complains that "Parameter #1 $builder of method Discord\Parts\Channel\Channel::sendMessage() expects Discord\Builders\MessageBuilder, string given." --- src/Discord/Parts/Channel/Channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Parts/Channel/Channel.php b/src/Discord/Parts/Channel/Channel.php index b9bc67be0..bb425c256 100644 --- a/src/Discord/Parts/Channel/Channel.php +++ b/src/Discord/Parts/Channel/Channel.php @@ -98,7 +98,7 @@ * @property InviteRepository $invites Invites in the channel. * @property StageInstanceRepository $stage_instances Stage instances in the channel. * - * @method ExtendedPromiseInterface sendMessage(MessageBuilder $builder) + * @method ExtendedPromiseInterface sendMessage(MessageBuilder|string $builder) */ class Channel extends Part implements Stringable { From 4074a4f81ce44a0a740c6d5026eba54d0df73d01 Mon Sep 17 00:00:00 2001 From: SQKo <87897282+SQKo@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:18:59 +0700 Subject: [PATCH 06/24] fix(message-builder): allow null on empty payload with files in multipart --- src/Discord/Builders/MessageBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord/Builders/MessageBuilder.php b/src/Discord/Builders/MessageBuilder.php index d5c3f1a69..5764108b1 100644 --- a/src/Discord/Builders/MessageBuilder.php +++ b/src/Discord/Builders/MessageBuilder.php @@ -624,12 +624,12 @@ public function toMultipart(bool $payload = true): Multipart /** * {@inheritDoc} */ - public function jsonSerialize(): array + public function jsonSerialize(): ?array { $empty = true; if (! empty($this->files)) { - $body = []; + $body = null; $empty = false; } From 9f0479d2f592a69a3528aaf457e874ccaaa918b8 Mon Sep 17 00:00:00 2001 From: SQKo <87897282+SQKo@users.noreply.github.com> Date: Sun, 21 Jul 2024 22:08:16 +0700 Subject: [PATCH 07/24] feat(thread): Add event only attribute 'newly_created' --- src/Discord/Parts/Thread/Thread.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Discord/Parts/Thread/Thread.php b/src/Discord/Parts/Thread/Thread.php index a81c7fcb3..8afe71b99 100644 --- a/src/Discord/Parts/Thread/Thread.php +++ b/src/Discord/Parts/Thread/Thread.php @@ -100,6 +100,9 @@ class Thread extends Part implements Stringable 'total_message_sent', 'flags', 'applied_tags', + + // events + 'newly_created', ]; /** From d0ed3de740231c8bc0a3a18352dba2ff08225ee6 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Sun, 28 Jul 2024 06:11:41 -0400 Subject: [PATCH 08/24] Fixed getAttribute to properly return null if value is not set --- src/Discord/Parts/Part.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Parts/Part.php b/src/Discord/Parts/Part.php index e7008691c..99e3be2fa 100644 --- a/src/Discord/Parts/Part.php +++ b/src/Discord/Parts/Part.php @@ -240,7 +240,7 @@ private function getAttribute(string $key) } if (! isset($this->attributes[$key])) { - return; + return null; } return $this->attributes[$key]; From 3a1aee0aed1d5c5b71ce4b1cf326a12fc660c1dd Mon Sep 17 00:00:00 2001 From: Micca Date: Mon, 5 Aug 2024 19:14:35 -0400 Subject: [PATCH 09/24] Fix voice error 4020 (#1248) Add type hint to 'd', preventing this from being sent as a string which is now rejected. --- src/Discord/Voice/VoiceClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Voice/VoiceClient.php b/src/Discord/Voice/VoiceClient.php index adcc51535..ed1e1505b 100644 --- a/src/Discord/Voice/VoiceClient.php +++ b/src/Discord/Voice/VoiceClient.php @@ -553,7 +553,7 @@ public function handleWebSocketConnection(WebSocket $ws): void $sendHeartbeat = function () { $this->send([ 'op' => Op::VOICE_HEARTBEAT, - 'd' => microtime(true), + 'd' => (int) microtime(true), ]); $this->logger->debug('sending heartbeat'); $this->emit('ws-heartbeat', []); From c96f679fe340d25bbce012d2457e67379a1e530b Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Wed, 28 Aug 2024 11:49:40 -0400 Subject: [PATCH 10/24] Update RoleRepository.php https://discord.com/developers/docs/resources/guild#get-guild-role --- src/Discord/Repository/Guild/RoleRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Discord/Repository/Guild/RoleRepository.php b/src/Discord/Repository/Guild/RoleRepository.php index 42fd8cd4a..e25592bc7 100755 --- a/src/Discord/Repository/Guild/RoleRepository.php +++ b/src/Discord/Repository/Guild/RoleRepository.php @@ -36,6 +36,7 @@ class RoleRepository extends AbstractRepository */ protected $endpoints = [ 'all' => Endpoint::GUILD_ROLES, + 'get' => Endpoint::GUILD_ROLE, 'create' => Endpoint::GUILD_ROLES, 'update' => Endpoint::GUILD_ROLE, 'delete' => Endpoint::GUILD_ROLE, From d81ec904361f439f774add846f5b8263ae916bc1 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Wed, 25 Sep 2024 10:38:33 -0400 Subject: [PATCH 11/24] =?UTF-8?q?=E2=9C=A8=20Application=20Emojis=20(#1252?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add EmojiRepository for the application endpoint --- src/Discord/Discord.php | 33 +++++---- src/Discord/Parts/User/Client.php | 3 + src/Discord/Repository/EmojiRepository.php | 82 ++++++++++++++++++++++ 3 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 src/Discord/Repository/EmojiRepository.php diff --git a/src/Discord/Discord.php b/src/Discord/Discord.php index e21f99330..d18576eac 100644 --- a/src/Discord/Discord.php +++ b/src/Discord/Discord.php @@ -21,6 +21,7 @@ use Discord\Http\Endpoint; use Discord\Http\Http; use Discord\Parts\Channel\Channel; +use Discord\Parts\Guild\Emoji; use Discord\Parts\Guild\Guild; use Discord\Parts\OAuth\Application; use Discord\Parts\Part; @@ -29,6 +30,7 @@ use Discord\Parts\User\Member; use Discord\Parts\User\User; use Discord\Repository\AbstractRepository; +use Discord\Repository\EmojiRepository; use Discord\Repository\GuildRepository; use Discord\Repository\PrivateChannelRepository; use Discord\Repository\UserRepository; @@ -61,20 +63,21 @@ * * @version 10.0.0 * - * @property string $id The unique identifier of the client. - * @property string $username The username of the client. - * @property string $password The password of the client (if they have provided it). - * @property string $email The email of the client. - * @property bool $verified Whether the client has verified their email. - * @property string $avatar The avatar URL of the client. - * @property string $avatar_hash The avatar hash of the client. - * @property string $discriminator The unique discriminator of the client. - * @property bool $bot Whether the client is a bot. - * @property User $user The user instance of the client. - * @property Application $application The OAuth2 application of the bot. - * @property GuildRepository $guilds - * @property PrivateChannelRepository $private_channels - * @property UserRepository $users + * @property string $id The unique identifier of the client. + * @property string $username The username of the client. + * @property string $password The password of the client (if they have provided it). + * @property string $email The email of the client. + * @property bool $verified Whether the client has verified their email. + * @property string $avatar The avatar URL of the client. + * @property string $avatar_hash The avatar hash of the client. + * @property string $discriminator The unique discriminator of the client. + * @property bool $bot Whether the client is a bot. + * @property User $user The user instance of the client. + * @property Application $application The OAuth2 application of the bot. + * @property GuildRepository $guilds + * @property PrivateChannelRepository $private_channels + * @property UserRepository $users + * @property EmojiRepository $emojis */ class Discord { @@ -322,7 +325,7 @@ class Discord /** * The cache configuration. * - * @var CacheConfig + * @var CacheConfig[] */ protected $cacheConfig; diff --git a/src/Discord/Parts/User/Client.php b/src/Discord/Parts/User/Client.php index b1845aec3..3748674c4 100644 --- a/src/Discord/Parts/User/Client.php +++ b/src/Discord/Parts/User/Client.php @@ -15,6 +15,7 @@ use Discord\Http\Endpoint; use Discord\Parts\OAuth\Application; use Discord\Parts\Part; +use Discord\Repository\EmojiRepository; use Discord\Repository\GuildRepository; use Discord\Repository\PrivateChannelRepository; use Discord\Repository\UserRepository; @@ -40,6 +41,7 @@ * @property User $user The user instance of the client. * @property Application $application The OAuth2 application of the bot. * + * @property EmojiRepository $emojis * @property GuildRepository $guilds * @property PrivateChannelRepository $private_channels * @property UserRepository $users @@ -71,6 +73,7 @@ class Client extends Part * {@inheritDoc} */ protected $repositories = [ + 'emojis' => EmojiRepository::class, 'guilds' => GuildRepository::class, 'private_channels' => PrivateChannelRepository::class, 'users' => UserRepository::class, diff --git a/src/Discord/Repository/EmojiRepository.php b/src/Discord/Repository/EmojiRepository.php new file mode 100644 index 000000000..2771358d7 --- /dev/null +++ b/src/Discord/Repository/EmojiRepository.php @@ -0,0 +1,82 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Repository; + +use Discord\Discord; +use Discord\Http\Endpoint; +use Discord\Parts\Guild\Emoji; +use React\Promise\ExtendedPromiseInterface; + +use function React\Promise\resolve; + +/** + * Contains emojis of an application. + * + * @see Emoji + * @see \Discord\Parts\User\Client + * + * @since 10.0.0 + * + * @method Emoji|null get(string $discrim, $key) + * @method Emoji|null pull(string|int $key, $default = null) + * @method Emoji|null first() + * @method Emoji|null last() + * @method Emoji|null find(callable $callback) + */ +class EmojiRepository extends AbstractRepository +{ + /** + * {@inheritDoc} + */ + protected $endpoints = [ + 'all' => Endpoint::APPLICATION_EMOJIS, + 'get' => Endpoint::APPLICATION_EMOJI, + 'create' => Endpoint::APPLICATION_EMOJIS, + 'delete' => Endpoint::APPLICATION_EMOJI, + 'update' => Endpoint::APPLICATION_EMOJI, + ]; + + /** + * {@inheritDoc} + */ + protected $class = Emoji::class; + + /** + * {@inheritDoc} + */ + public function __construct(Discord $discord, array $vars = []) + { + $vars['application_id'] = $discord->application->id; + + parent::__construct($discord, $vars); + } + + /** + * @param object $response + * + * @return ExtendedPromiseInterface + */ + protected function cacheFreshen($response): ExtendedPromiseInterface + { + foreach ($response as $value) foreach ($value as $value) { + $value = array_merge($this->vars, (array) $value); + $part = $this->factory->create($this->class, $value, true); + $items[$part->{$this->discrim}] = $part; + } + + if (empty($items)) { + return resolve($this); + } + + return $this->cache->setMultiple($items)->then(fn ($success) => $this); + } +} From 3eefd3ce6fd996ca06e27cd5671712542d0ef106 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 09:22:52 -0400 Subject: [PATCH 12/24] =?UTF-8?q?=E2=9C=A8=20Soundboards=20(#1253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Discord/Parts/Guild/Guild.php | 3 + src/Discord/Parts/Guild/Sound.php | 113 ++++++++++++++++++ src/Discord/Parts/User/Client.php | 3 + .../Repository/Guild/SoundRepository.php | 79 ++++++++++++ src/Discord/Repository/SoundRepository.php | 52 ++++++++ 5 files changed, 250 insertions(+) create mode 100644 src/Discord/Parts/Guild/Sound.php create mode 100644 src/Discord/Repository/Guild/SoundRepository.php create mode 100644 src/Discord/Repository/SoundRepository.php diff --git a/src/Discord/Parts/Guild/Guild.php b/src/Discord/Parts/Guild/Guild.php index 2379718a2..323542598 100644 --- a/src/Discord/Parts/Guild/Guild.php +++ b/src/Discord/Parts/Guild/Guild.php @@ -35,6 +35,7 @@ use Discord\Repository\Guild\AutoModerationRuleRepository; use Discord\Repository\Guild\CommandPermissionsRepository; use Discord\Repository\Guild\GuildCommandRepository; +use Discord\Repository\Guild\SoundRepository; use Discord\Repository\Guild\StickerRepository; use Discord\Repository\Guild\ScheduledEventRepository; use Discord\Repository\Guild\GuildTemplateRepository; @@ -144,6 +145,7 @@ * @property CommandPermissionsRepository $command_permissions * @property IntegrationRepository $integrations * @property InviteRepository $invites + * @property SoundRepository $sounds * @property GuildTemplateRepository $templates */ class Guild extends Part @@ -296,6 +298,7 @@ class Guild extends Part 'command_permissions' => CommandPermissionsRepository::class, 'integrations' => IntegrationRepository::class, 'invites' => InviteRepository::class, + 'sounds' => SoundRepository::class, 'templates' => GuildTemplateRepository::class, ]; diff --git a/src/Discord/Parts/Guild/Sound.php b/src/Discord/Parts/Guild/Sound.php new file mode 100644 index 000000000..e0a70050a --- /dev/null +++ b/src/Discord/Parts/Guild/Sound.php @@ -0,0 +1,113 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Parts\Guild; + +use Discord\Parts\Part; +use Discord\Parts\User\User; +use Stringable; + +/** + * An sound object represents a soundboard sound. + * + * @link https://discord.com/developers/docs/resources/soundboard + * + * @since 10.0.0 + * + * @property string $name The name of this sound. + * @property ?string $sound_id The identifier for this sound. + * @property double $volume The volume of this sound, from 0 to 1. + * @property ?string $emoji_id The identifier for this sound's custom emoji. + * @property ?string $emoji_name The unicode character of this sound's standard emoji. + * @property ?string $guild_id The identifier of the guild this sound is in. + * @property bool $available Whether this sound can be used, may be false due to loss of Server Boosts. + * @property User|null $user The user who created this sound. + * @property-read Guild|null $guild The guild that owns the sound. + */ +class Sound extends Part implements Stringable +{ + /** + * {@inheritDoc} + */ + protected $fillable = [ + 'name', + 'sound_id', + 'volume', + 'emoji_id', + 'emoji_name', + 'guild_id', + 'available', + 'user', + ]; + + /** + * Returns the guild attribute. + * + * @return Guild|null The guild the sound belongs to. + */ + protected function getGuildAttribute(): ?Guild + { + return $this->discord->guilds->get('id', $this->guild_id); + } + + /** + * Gets the user that created the sound. + * + * @return User|null + */ + protected function getUserAttribute(): ?User + { + if (! isset($this->attributes['user'])) { + return null; + } + + if ($user = $this->discord->users->get('id', $this->attributes['user']->id)) { + return $user; + } + + return $this->factory->part(User::class, (array) $this->attributes['user'], true); + } + + /** + * Converts the sound to a string. + * + * @return string + */ + public function __toString(): string + { + return $this->name; + } + + /** + * {@inheritDoc} + * + * @link https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound + */ + public function getUpdatableAttributes(): array + { + return $this->makeOptionalAttributes([ + 'name' => $this->name, + 'volume' => $this->volume, + 'emoji_id' => $this->emoji_id, + 'emoji_name' => $this->emoji_name, + ]); + } + + /** + * {@inheritDoc} + */ + public function getRepositoryAttributes(): array + { + return [ + 'sound_id' => $this->sound_id, + ]; + } +} diff --git a/src/Discord/Parts/User/Client.php b/src/Discord/Parts/User/Client.php index 3748674c4..5b4532914 100644 --- a/src/Discord/Parts/User/Client.php +++ b/src/Discord/Parts/User/Client.php @@ -18,6 +18,7 @@ use Discord\Repository\EmojiRepository; use Discord\Repository\GuildRepository; use Discord\Repository\PrivateChannelRepository; +use Discord\Repository\SoundRepository; use Discord\Repository\UserRepository; use React\Promise\ExtendedPromiseInterface; @@ -44,6 +45,7 @@ * @property EmojiRepository $emojis * @property GuildRepository $guilds * @property PrivateChannelRepository $private_channels + * @property SoundRepository $sounds * @property UserRepository $users */ class Client extends Part @@ -76,6 +78,7 @@ class Client extends Part 'emojis' => EmojiRepository::class, 'guilds' => GuildRepository::class, 'private_channels' => PrivateChannelRepository::class, + 'sounds' => SoundRepository::class, 'users' => UserRepository::class, ]; diff --git a/src/Discord/Repository/Guild/SoundRepository.php b/src/Discord/Repository/Guild/SoundRepository.php new file mode 100644 index 000000000..dc5236e7d --- /dev/null +++ b/src/Discord/Repository/Guild/SoundRepository.php @@ -0,0 +1,79 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Repository\Guild; + +use Discord\Http\Endpoint; +use Discord\Parts\Guild\Sound; +use Discord\Repository\AbstractRepository; +use React\Promise\ExtendedPromiseInterface; + +use function React\Promise\resolve; + +/** + * Contains sounds of a guild. + * + * @see Sound + * @see \Discord\Parts\Guild\Guild + * + * @since 10.0.0 + * + * @method Sound|null get(string $discrim, $key) + * @method Sound|null pull(string|int $key, $default = null) + * @method Sound|null first() + * @method Sound|null last() + * @method Sound|null find(callable $callback) + */ +class SoundRepository extends AbstractRepository +{ + /** + * The discriminator. + * + * @var string Discriminator. + */ + protected $discrim = 'sound_id'; + + /** + * {@inheritDoc} + */ + protected $endpoints = [ + 'all' => Endpoint::GUILD_SOUNDBOARD_SOUNDS, + 'get' => Endpoint::GUILD_SOUNDBOARD_SOUND, + 'create' => Endpoint::GUILD_SOUNDBOARD_SOUNDS, + 'delete' => Endpoint::GUILD_SOUNDBOARD_SOUND, + 'update' => Endpoint::GUILD_SOUNDBOARD_SOUND, + ]; + + /** + * {@inheritDoc} + */ + protected $class = Sound::class; + + /** + * @param object $response + * + * @return ExtendedPromiseInterface + */ + protected function cacheFreshen($response): ExtendedPromiseInterface + { + foreach ($response as $value) foreach ($value as $value) { + $value = array_merge($this->vars, (array) $value); + $part = $this->factory->create($this->class, $value, true); + $items[$part->{$this->discrim}] = $part; + } + + if (empty($items)) { + return resolve($this); + } + + return $this->cache->setMultiple($items)->then(fn ($success) => $this); + } +} diff --git a/src/Discord/Repository/SoundRepository.php b/src/Discord/Repository/SoundRepository.php new file mode 100644 index 000000000..47312787b --- /dev/null +++ b/src/Discord/Repository/SoundRepository.php @@ -0,0 +1,52 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Repository; + +use Discord\Http\Endpoint; +use Discord\Parts\Guild\Sound; +use Discord\Repository\AbstractRepository; + +/** + * Contains sounds of a guild. + * + * @see Sound + * @see \Discord\Parts\Guild\Guild + * + * @since 10.0.0 + * + * @method Sound|null get(string $discrim, $key) + * @method Sound|null pull(string|int $key, $default = null) + * @method Sound|null first() + * @method Sound|null last() + * @method Sound|null find(callable $callback) + */ +class SoundRepository extends AbstractRepository +{ + /** + * The discriminator. + * + * @var string Discriminator. + */ + protected $discrim = 'sound_id'; + + /** + * {@inheritDoc} + */ + protected $endpoints = [ + 'all' => Endpoint::SOUNDBOARD_DEFAULT_SOUNDS, + ]; + + /** + * {@inheritDoc} + */ + protected $class = Sound::class; +} From aa759dfa559ad0c26d8b39300135a59eb252d5fd Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 09:28:43 -0400 Subject: [PATCH 13/24] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c8b3ab3a3..f5e637c03 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ DiscordPHP ==== -[![Latest Stable Version](https://poser.pugx.org/team-reflex/discord-php/v)](https://packagist.org/packages/team-reflex/discord-php) [![Latest Unstable Version](http://poser.pugx.org/team-reflex/discord-php/v/unstable)](https://packagist.org/packages/team-reflex/discord-php) [![Total Downloads](https://poser.pugx.org/team-reflex/discord-php/downloads)](https://packagist.org/packages/team-reflex/discord-php) [![PHP Version Require](https://poser.pugx.org/team-reflex/discord-php/require/php)](https://packagist.org/packages/team-reflex/discord-php) +[![Latest Stable Version](https://poser.pugx.org/team-reflex/discord-php/v)](https://packagist.org/packages/team-reflex/discord-php) [![Latest Unstable Version](https://poser.pugx.org/team-reflex/discord-php/v/unstable)](https://packagist.org/packages/team-reflex/discord-php) [![Total Downloads](https://poser.pugx.org/team-reflex/discord-php/downloads)](https://packagist.org/packages/team-reflex/discord-php) [![PHP Version Require](https://poser.pugx.org/team-reflex/discord-php/require/php)](https://packagist.org/packages/team-reflex/discord-php) [![PHP Discorders](https://discord.com/api/guilds/115233111977099271/widget.png?style=banner1)](https://discord.gg/dphp) From bbe6c34d0766d3f68661ea6300a1c16da919d0b0 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 10:14:27 -0400 Subject: [PATCH 14/24] getURL for Sounds --- src/Discord/Parts/Guild/Sound.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Discord/Parts/Guild/Sound.php b/src/Discord/Parts/Guild/Sound.php index e0a70050a..e7ffbbb77 100644 --- a/src/Discord/Parts/Guild/Sound.php +++ b/src/Discord/Parts/Guild/Sound.php @@ -76,6 +76,20 @@ protected function getUserAttribute(): ?User return $this->factory->part(User::class, (array) $this->attributes['user'], true); } + /** + * Returns the URL of the sound. + * + * @return string|null + */ + public function getURL(): ?string + { + if (! isset($this->sound_id)) { + return null; + } + + return "https://cdn.discordapp.com/soundboard-sounds/{$this->sound_id}"; + } + /** * Converts the sound to a string. * From b6bbe5eb00468e6bd1754619fdd946e3389e382c Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 11:13:36 -0400 Subject: [PATCH 15/24] approximate_user_install_count --- src/Discord/Parts/OAuth/Application.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Discord/Parts/OAuth/Application.php b/src/Discord/Parts/OAuth/Application.php index 2bc616410..3ef6120a2 100644 --- a/src/Discord/Parts/OAuth/Application.php +++ b/src/Discord/Parts/OAuth/Application.php @@ -44,6 +44,7 @@ * @property string|null $cover_image_hash The application's default rich presence invite cover image hash. * @property int $flags The application's public flags. * @property int|null $approximate_guild_count The application's approximate count of the app's guild membership. + * @property int|null $approximate_user_install_count The approximate count of users that have installed the app. * @property string[]|null $redirect_uris Array of redirect URIs for the application. * @property string|null $interactions_endpoint_url The interactions endpoint URL for the application. * @property string|null $role_connections_verification_url The application's role connection verification entry point, which when configured will render the app as a verification method in the guild role verification configuration. @@ -81,6 +82,7 @@ class Application extends Part 'role_connections_verification_url', 'owner', 'approximate_guild_count', + 'approximate_user_install_count', // 'interactions_event_types', // 'interactions_version', // 'explicit_content_filter', From 5dd24c700491f3d12b1fdf319c92d8f7195e2e86 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 11:26:21 -0400 Subject: [PATCH 16/24] Auto Moderation Member Profile Rule @see https://discord.com/developers/docs/change-log#auto-moderation-member-profile-rule --- src/Discord/Parts/Guild/AutoModeration/Action.php | 1 + src/Discord/Parts/Guild/AutoModeration/Rule.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Discord/Parts/Guild/AutoModeration/Action.php b/src/Discord/Parts/Guild/AutoModeration/Action.php index 511c5ca1d..9e982ef66 100644 --- a/src/Discord/Parts/Guild/AutoModeration/Action.php +++ b/src/Discord/Parts/Guild/AutoModeration/Action.php @@ -36,6 +36,7 @@ class Action extends Part public const TYPE_BLOCK_MESSAGE = 1; public const TYPE_SEND_ALERT_MESSAGE = 2; public const TYPE_TIMEOUT = 3; + public const TYPE_BLOCK_MEMBER_INTERACTION = 4; /** * Get the Metadata Attributes. diff --git a/src/Discord/Parts/Guild/AutoModeration/Rule.php b/src/Discord/Parts/Guild/AutoModeration/Rule.php index fdb78737b..935f3e277 100644 --- a/src/Discord/Parts/Guild/AutoModeration/Rule.php +++ b/src/Discord/Parts/Guild/AutoModeration/Rule.php @@ -67,6 +67,7 @@ class Rule extends Part public const TRIGGER_TYPE_SPAM = 3; public const TRIGGER_TYPE_KEYWORD_PRESET = 4; public const TRIGGER_TYPE_MENTION_SPAM = 5; + public const TRIGGER_TYPE_PROFILE = 6; public const KEYWORD_PRESET_TYPE_PROFANITY = 1; public const KEYWORD_PRESET_TYPE_SEXUAL_CONTENT = 2; @@ -180,7 +181,7 @@ public function getCreatableAttributes(): array 'exempt_channels', ]); - if (in_array($this->trigger_type, [self::TRIGGER_TYPE_KEYWORD, self::TRIGGER_TYPE_KEYWORD_PRESET, self::TRIGGER_TYPE_MENTION_SPAM])) { + if (in_array($this->trigger_type, [self::TRIGGER_TYPE_KEYWORD, self::TRIGGER_TYPE_KEYWORD_PRESET, self::TRIGGER_TYPE_MENTION_SPAM, self::TRIGGER_TYPE_PROFILE])) { $attr['trigger_metadata'] = $this->trigger_metadata; } From 934b147d1751038dfb39a139a497c92821150c69 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 11:44:19 -0400 Subject: [PATCH 17/24] enforce_nonce and poll params for MessageBuilder --- src/Discord/Builders/MessageBuilder.php | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/Discord/Builders/MessageBuilder.php b/src/Discord/Builders/MessageBuilder.php index 5764108b1..bd5649d15 100644 --- a/src/Discord/Builders/MessageBuilder.php +++ b/src/Discord/Builders/MessageBuilder.php @@ -124,6 +124,20 @@ class MessageBuilder implements JsonSerializable */ private $flags; + /** + * Whether to enforce the nonce. + * + * @var bool|null + */ + private $enforce_nonce; + + /** + * A poll! + * + * @var mixed + */ + private $poll; + /** * Creates a new message builder. * @@ -174,6 +188,36 @@ public function setNonce($nonce = null): self return $this; } + /** + * If true and nonce is present, it will be checked for uniqueness in the past few minutes. + * If another message was created by the same author with the same nonce, + * that message will be returned and no new message will be created. + * + * @param bool $enforce_nonce + * + * @return $this + */ + public function setEnforceNonce(bool $enforce_nonce = true): self + { + $this->enforce_nonce = $enforce_nonce; + + return $this; + } + + /** + * Sets the poll of the message. + * + * @param mixed $poll Poll object. + * + * @return $this + */ + public function setPoll($poll): self + { + $this->poll = $poll; + + return $this; + } + /** * Override the default username of the webhook. Only used for executing webhook. * @@ -691,6 +735,14 @@ public function jsonSerialize(): ?array throw new RequestFailedException('You cannot send an empty message. Set the content or add an embed or file.'); } + if (isset($this->enforce_nonce)) { + $body['enforce_nonce'] = $this->enforce_nonce; + } + + if (isset($this->poll)) { + $body['poll'] = $this->poll; + } + return $body; } } From 7f85a8dc88ae34b69c578f13a32addc9f55f2978 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 12:18:29 -0400 Subject: [PATCH 18/24] Add missing params and methods to SelectMenu @see https://discord.com/developers/docs/interactions/message-components#select-menus --- .../Builders/Components/SelectMenu.php | 143 +++++++++++++++++- 1 file changed, 142 insertions(+), 1 deletion(-) diff --git a/src/Discord/Builders/Components/SelectMenu.php b/src/Discord/Builders/Components/SelectMenu.php index 136e6a7b2..468b6b56a 100644 --- a/src/Discord/Builders/Components/SelectMenu.php +++ b/src/Discord/Builders/Components/SelectMenu.php @@ -31,6 +31,21 @@ */ abstract class SelectMenu extends Component { + public const ALLOWED_TYPES = [ + self::TYPE_STRING_SELECT, + self::TYPE_USER_SELECT, + self::TYPE_ROLE_SELECT, + self::TYPE_MENTIONABLE_SELECT, + self::TYPE_CHANNEL_SELECT, + ]; + + /** + * Type of select menu component (text: 3, user: 5, role: 6, mentionable: 7, channels: 8) + * + * @var integer + */ + protected $type; + /** * Custom ID to identify the select menu. * @@ -38,6 +53,20 @@ abstract class SelectMenu extends Component */ protected $custom_id; + /** + * Specified choices in a select menu (only required and available for string selects (type 3); max 25 + * + * @var array|null + */ + protected $options; + + /** + * List of channel types to include in the channel select component (type 8) + * + * @var array|null + */ + protected $channel_types; + /** * Placeholder string to display if nothing is selected. Maximum 150 characters. * @@ -45,6 +74,14 @@ abstract class SelectMenu extends Component */ protected $placeholder; + /** + * List of default values for auto-populated select menu components; + * number of default values must be in the range defined by min_values and max_values + * + * @var array|null + */ + protected $default_values; + /** * Minimum number of options that must be selected. * Default 1, minimum 0, maximum 25. @@ -104,12 +141,33 @@ public static function new(?string $custom_id = null): self return new static($custom_id); } + /** + * Sets the type for the select menu. + * (text: 3, user: 5, role: 6, mentionable: 7, channels: 8) + * + * @param int $type + * + * @throws \InvalidArgumentException + * + * @return string + */ + public function setType(int $type): self + { + if (! in_array($type, self::ALLOWED_TYPES)) { + throw new \InvalidArgumentException('Invalid select menu type.'); + } + + $this->type = $type; + + return $this; + } + /** * Sets the custom ID for the select menu. * * @param string $custom_id * - * @throws \LengthException + * @throws \LengthException If the custom ID is longer than 100 characters. * * @return $this */ @@ -124,6 +182,49 @@ public function setCustomId($custom_id): self return $this; } + /** + * Specified choices in a select menu (only required and available for string selects (type 3); max 25 + * + * @param array $options + * + * @throws \InvalidArgumentException If the select menu type is not `TYPE_STRING_SELECT`. + * + * @return $this + */ + public function setOptions(array $options): self + { + if ($this->type != self::TYPE_STRING_SELECT) { + throw new \InvalidArgumentException('Options can only be set for string selects.'); + } + + $this->options = $options; + + return $this; + } + + /** + * Sets the channel types for the select menu. + * + * This method is only applicable if the select menu type is `TYPE_CHANNEL_SELECT`. + * If the select menu type is not `TYPE_CHANNEL_SELECT`, an `InvalidArgumentException` will be thrown. + * + * @param array $channel_types + * + * @throws \InvalidArgumentException If the select menu type is not `TYPE_CHANNEL_SELECT`. + * + * @return $this + */ + public function setChannelTypes(array $channel_types): self + { + if ($this->type != self::TYPE_CHANNEL_SELECT) { + throw new \InvalidArgumentException('Channel types can only be set for channel selects.'); + } + + $this->channel_types = $channel_types; + + return $this; + } + /** * Sets the placeholder string to display if nothing is selected. * @@ -290,6 +391,16 @@ public function removeListener(): self return $this->setListener(null, $this->discord); } + /** + * Returns the type of the select menu. + * + * @return int + */ + public function getType(): int + { + return $this->type; + } + /** * Returns the Custom ID of the select menu. * @@ -300,6 +411,26 @@ public function getCustomId(): string return $this->custom_id; } + /** + * Returns the options of the select menu. + * + * @return array|null + */ + public function getOptions(): ?array + { + return $this->options; + } + + /** + * Returns the channel types of the select menu. + * + * @return array|null + */ + public function getChannelTypes(): ?array + { + return $this->channel_types; + } + /** * Returns the placeholder string of the select menu. * @@ -310,6 +441,16 @@ public function getPlaceholder(): ?string return $this->placeholder; } + /** + * Returns the default values of the select menu. + * + * @return array|null + */ + public function getDefaultValues(): ?array + { + return $this->default_values; + } + /** * Returns the minimum number of options that must be selected. * From f9ee20adf53849336fbc119e6bbf2d614c8e3789 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 12:24:53 -0400 Subject: [PATCH 19/24] setDefaultValues --- .../Builders/Components/SelectMenu.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Discord/Builders/Components/SelectMenu.php b/src/Discord/Builders/Components/SelectMenu.php index 468b6b56a..54cb29098 100644 --- a/src/Discord/Builders/Components/SelectMenu.php +++ b/src/Discord/Builders/Components/SelectMenu.php @@ -31,14 +31,6 @@ */ abstract class SelectMenu extends Component { - public const ALLOWED_TYPES = [ - self::TYPE_STRING_SELECT, - self::TYPE_USER_SELECT, - self::TYPE_ROLE_SELECT, - self::TYPE_MENTIONABLE_SELECT, - self::TYPE_CHANNEL_SELECT, - ]; - /** * Type of select menu component (text: 3, user: 5, role: 6, mentionable: 7, channels: 8) * @@ -153,7 +145,8 @@ public static function new(?string $custom_id = null): self */ public function setType(int $type): self { - if (! in_array($type, self::ALLOWED_TYPES)) { + $allowed_types = [self::TYPE_STRING_SELECT, self::TYPE_USER_SELECT, self::TYPE_ROLE_SELECT, self::TYPE_MENTIONABLE_SELECT, self::TYPE_CHANNEL_SELECT]; + if (! in_array($type, $allowed_types)) { throw new \InvalidArgumentException('Invalid select menu type.'); } @@ -245,6 +238,17 @@ public function setPlaceholder(?string $placeholder): self return $this; } + public function setDefaultValues(?array $default_values): self + { + $allowed_types = [self::TYPE_USER_SELECT, self::TYPE_ROLE_SELECT, self::TYPE_MENTIONABLE_SELECT, self::TYPE_CHANNEL_SELECT]; + if (! in_array($this->type, $allowed_types)) { + throw new \InvalidArgumentException('Default values can only be set for user, role, mentionable, and channel selects.'); + } + $this->default_values = $default_values; + + return $this; + } + /** * Sets the minimum number of options which must be chosen. * From d0611216e6012282f379864385a7a72d1662020b Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 12:45:44 -0400 Subject: [PATCH 20/24] GUILD_MEDIA channel type --- src/Discord/Parts/Channel/Channel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Discord/Parts/Channel/Channel.php b/src/Discord/Parts/Channel/Channel.php index bb425c256..723ed1bfe 100644 --- a/src/Discord/Parts/Channel/Channel.php +++ b/src/Discord/Parts/Channel/Channel.php @@ -114,6 +114,7 @@ class Channel extends Part implements Stringable public const TYPE_GUILD_STAGE_VOICE = 13; public const TYPE_GUILD_DIRECTORY = 14; public const TYPE_GUILD_FORUM = 15; + public const TYPE_GUILD_MEDIA = 16; /** @deprecated 10.0.0 Use `Channel::TYPE_GUILD_TEXT` */ public const TYPE_TEXT = self::TYPE_GUILD_TEXT; From b936641750d461eb071b9ac6f4ce08d7d65ef56c Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 12:57:26 -0400 Subject: [PATCH 21/24] Fix doc block for Application SoundRepository --- src/Discord/Repository/SoundRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Repository/SoundRepository.php b/src/Discord/Repository/SoundRepository.php index 47312787b..46752bc8d 100644 --- a/src/Discord/Repository/SoundRepository.php +++ b/src/Discord/Repository/SoundRepository.php @@ -16,7 +16,7 @@ use Discord\Repository\AbstractRepository; /** - * Contains sounds of a guild. + * Contains sounds of an application. * * @see Sound * @see \Discord\Parts\Guild\Guild From 959f24a99a9d99842e18f0789d43cc67f4e450a3 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 13:09:29 -0400 Subject: [PATCH 22/24] Fix deprecations and return type consistency --- src/Discord/Discord.php | 8 ++++---- src/Discord/Parts/Channel/Channel.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Discord/Discord.php b/src/Discord/Discord.php index d18576eac..9c6b276ea 100644 --- a/src/Discord/Discord.php +++ b/src/Discord/Discord.php @@ -21,7 +21,6 @@ use Discord\Http\Endpoint; use Discord\Http\Http; use Discord\Parts\Channel\Channel; -use Discord\Parts\Guild\Emoji; use Discord\Parts\Guild\Guild; use Discord\Parts\OAuth\Application; use Discord\Parts\Part; @@ -44,11 +43,12 @@ use Monolog\Formatter\LineFormatter; use Monolog\Handler\StreamHandler; use Monolog\Logger as Monolog; +use Monolog\Level; use Psr\Log\LoggerInterface; use Ratchet\Client\Connector; use Ratchet\Client\WebSocket; use Ratchet\RFC6455\Messaging\Message; -use React\EventLoop\Factory as LoopFactory; +use React\EventLoop\Loop; use React\EventLoop\LoopInterface; use React\EventLoop\TimerInterface; use React\Promise\ExtendedPromiseInterface; @@ -1429,10 +1429,10 @@ protected function resolveOptions(array $options = []): array $options = $resolver->resolve($options); - $options['loop'] ??= LoopFactory::create(); + $options['loop'] ??= Loop::get(); if (null === $options['logger']) { - $streamHandler = new StreamHandler('php://stdout', Monolog::DEBUG); + $streamHandler = new StreamHandler('php://stdout', Level::Debug); $lineFormatter = new LineFormatter(null, null, true, true); $streamHandler->setFormatter($lineFormatter); $logger = new Monolog('DiscordPHP', [$streamHandler]); diff --git a/src/Discord/Parts/Channel/Channel.php b/src/Discord/Parts/Channel/Channel.php index 723ed1bfe..03ffe14d5 100644 --- a/src/Discord/Parts/Channel/Channel.php +++ b/src/Discord/Parts/Channel/Channel.php @@ -913,14 +913,14 @@ protected function setPermissionOverwritesAttribute(?array $overwrites): void */ protected function getPermissionOverwritesAttribute(): ?array { - $overwrites = null; + $overwrites = []; /** @var Overwrite */ foreach ($this->overwrites as $overwrite) { $overwrites[] = $overwrite->getRawAttributes(); } - return $overwrites ?? $this->attributes['permission_overwrites'] ?? null; + return ! empty($overwrites) ? $overwrites : ($this->attributes['permission_overwrites'] ?? null); } /** From 763d4bc35c207db10f0bd655020df6a3290492f4 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 13:11:27 -0400 Subject: [PATCH 23/24] Cannot redeclare non-readonly property as readonly. --- src/Discord/Repository/AbstractRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Repository/AbstractRepository.php b/src/Discord/Repository/AbstractRepository.php index 39aa8cfc9..9b461b4fa 100755 --- a/src/Discord/Repository/AbstractRepository.php +++ b/src/Discord/Repository/AbstractRepository.php @@ -35,7 +35,7 @@ * @author Aaron Scherer * @author David Cole * - * @property-read string $discrim The discriminator. + * @property string $discrim The discriminator. * @property-read CacheWrapper $cache The react/cache wrapper. */ abstract class AbstractRepository extends Collection From af54bcf116261916cb1cecab4208fc9f5dfe6b08 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 26 Sep 2024 13:17:24 -0400 Subject: [PATCH 24/24] Clarification of AbstractRepository deprecations --- src/Discord/Repository/AbstractRepository.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Discord/Repository/AbstractRepository.php b/src/Discord/Repository/AbstractRepository.php index 9b461b4fa..0124cadd7 100755 --- a/src/Discord/Repository/AbstractRepository.php +++ b/src/Discord/Repository/AbstractRepository.php @@ -466,6 +466,7 @@ public function cachePull($key, $default = null): ExtendedPromiseInterface * Pushes a single item to the repository. * * @deprecated 10.0.0 Use async `$repository->cache->set()` + * This method is deprecated for userland code but can still be used internally within the library. * * @param Part $item * @@ -649,6 +650,7 @@ public function keys(): array * If the repository has an offset. * * @deprecated 10.0.0 Use async `$repository->cache->has()` + * This method is deprecated for userland code but can still be used internally within the library. * * @param string|int $offset * @@ -663,6 +665,7 @@ public function offsetExists($offset): bool * Gets a part from the repository. * * @deprecated 10.0.0 Use async `$repository->cacheGet()` or sync `$repository->get()` + * This method is deprecated for userland code but can still be used internally within the library. * * @param string|int $offset *