diff --git a/src/Discord/Builders/CommandAttributes.php b/src/Discord/Builders/CommandAttributes.php index b743c146e..9a25c22c4 100644 --- a/src/Discord/Builders/CommandAttributes.php +++ b/src/Discord/Builders/CommandAttributes.php @@ -11,6 +11,8 @@ namespace Discord\Builders; +use Discord\Helpers\Collection; +use Discord\Helpers\CollectionInterface; use Discord\Parts\Interactions\Command\Command; use Discord\Parts\Interactions\Command\Option; @@ -24,17 +26,17 @@ * * @since 7.1.0 * - * @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[]|null $description_localizations Localization dictionary for the description field. Values follow the same restrictions as description. - * @property \Discord\Helpers\CollectionInterface|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`. + * @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[]|null $description_localizations Localization dictionary for the description field. Values follow the same restrictions as description. + * @property CollectionInterface|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 { @@ -257,7 +259,7 @@ public function addOption(Option $option): self throw new \OverflowException('Command can only have a maximum of 25 options.'); } - $this->options ??= []; + $this->options ??= Collection::for(Option::class, 'name'); $this->options[] = $option; @@ -293,7 +295,7 @@ public function removeOption(Option $option): self */ public function clearOptions(): self { - $this->options = []; + $this->options = Collection::for(Option::class, 'name'); return $this; }