discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
977 stars 236 forks source link

update getFieldsAttribute() #1145

Closed key2peace closed 1 year ago

key2peace commented 1 year ago

this was the only function actually using Collections. all other fields related functions (addField, setFieldAttribute) use plain array manipulation. another thing is, this field is optional and should therefor return null if the attribute is not set.

SQKo commented 1 year ago

Other fields aren't actually null due to attributesHelper() creating the object, so it wouldn't be consistent.

Discord\Parts\Embed\Embed Object
(
    [title] =>
    [type] =>
    [description] =>
    [url] =>
    [timestamp] =>
    [color] => 16777215
    [footer] => Discord\Parts\Embed\Footer Object
        (
            [text] =>
            [icon_url] =>
            [proxy_icon_url] =>
        )

    [image] => Discord\Parts\Embed\Image Object
        (
            [url] =>
            [proxy_url] =>
            [height] =>
            [width] =>
        )

    [thumbnail] => Discord\Parts\Embed\Image Object
        (
            [url] =>
            [proxy_url] =>
            [height] =>
            [width] =>
        )

    [video] => Discord\Parts\Embed\Video Object
        (
            [url] =>
            [proxy_url] =>
            [height] =>
            [width] =>
        )

    [provider] =>
    [author] => Discord\Parts\Embed\Author Object
        (
            [name] =>
            [url] =>
            [icon_url] =>
            [proxy_icon_url] =>
        )

    [fields] => Discord\Helpers\Collection Object
        (
            [0] => Discord\Parts\Embed\Field Object
                (
                    [name] => ​
                    [value] => ​
                    [inline] =>
                )

            [1] => Discord\Parts\Embed\Field Object
                (
                    [name] => ​
                    [value] => ​
                    [inline] =>
                )

        )

)

I must've mistaken when documenting the @property

In future if we move out the builder functions to separate class then we can consider making the Part attributes actually optional just like according the discord api spec