Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PollResults to correctly map to an array of PollAnswerCount #1279

Merged
merged 4 commits into from
Jan 18, 2025

Conversation

sweptsquash
Copy link
Contributor

While working on a small integration utilizing Channel Polls, I encountered an issue where retrieving the answer_counts unexpectedly returned a singular entity instead of an array of PollAnswerCount objects. This behavior was inconsistent with the expected structure and functionality.

This PR addresses the issue by ensuring that the answer_counts object is properly mapped into an array of PollAnswerCount objects, aligning with the intended design and improving data handling.

Discord\Parts\Channel\Poll\PollAnswerCount^ {#3876
  #http: Discord\Http\Http^ {#3813}
  #factory: Discord\Factory\Factory^ {#3064}
  #discord: Discord\Discord^ {#3856}
  +scriptData: null
  #fillable: array:3 [
    0 => "id"
    1 => "count"
    2 => "me_voted"
  ]
  #attributes: []
  #visible: []
  #hidden: []
  #repositories: []
  #repositories_cache: []
  +created: true
  id: null
  count: null
  me_voted: null
}

@sweptsquash
Copy link
Contributor Author

@valzargaming Please let me know if you're happy with me making use of the collection helper here or if you would prefer me to use an alternative method.

@valzargaming
Copy link
Member

valzargaming commented Jan 18, 2025

I'm a bit confused why you're creating a new Collection object only to use it's ArrayAccess properties with ->push and then converting it back to an array. Why not just use $var []= $value or leave it as a Collection?

@sweptsquash
Copy link
Contributor Author

I'm a bit confused why you're creating a new Collection object only to use it's ArrayAccess properties with ->push and then converting it back to an array. Why not just use $var []= $value or leave it as a Collection?

Fair point, I've pushed a commit to bring this more inline with similar methods and now return the CollectionInterface

valzargaming
valzargaming previously approved these changes Jan 18, 2025
@valzargaming valzargaming merged commit 442cb56 into discord-php:master Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants