disnake icon indicating copy to clipboard operation
disnake copied to clipboard

feat(polls): implement Polls

Open Snipy7374 opened this issue 1 year ago • 2 comments

Summary

  • Closes GH-1175

Notes:

  • Emojis in PollMedia doesn't work yet... idk if this is an issue on my code or on the API
  • I still haven't tested sending Poll(s) on interaction responses and on Webhook(s) because that still returns 403 (Forbidden)
  • I followed the discord api docs to name things, but if you have suggestions they are welcome, for example i feel like the new events names may be too long
  • In the future the question field on Poll will be able to accept a PollMedia too, and PollMedia will likely supports new things
  • Messages that contain a Poll can't be edited after sending (yet), tho in the future this shouldn't require much code changes
  • Rn sending messages that contains Poll(s) can't have any other field set, this will not require any code change in the future since i'm not doing any check

Doubts: ~~I feel like i'm passing way too many arguments for the new events? What's your opinion?~~ Solved

  • Should we check for the number of answers the user is passing to construct the Poll? The maximum allowed is 10 answers per poll

~~I have a typing (skill) issue at poll.py/PollAnswer#245 what am i supposed to do there?~~ Solved

~~Should we make answers and polls be EQ comparable in some way? (we could use the internal message object, if set, to check if two polls are equals)~~ Doesn't make sense on second thought

Checklist

  • [x] If code changes were made, then they have been tested
    • [x] I have updated the documentation to reflect the changes
    • [x] I have formatted the code properly by running pdm lint
    • [x] I have type-checked the code by running pdm pyright
  • [ ] This PR fixes an issue
  • [x] This PR adds something new (e.g. new method or parameters)
  • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • [ ] This PR is not a code change (e.g. documentation, README, ...)

Snipy7374 avatar Mar 25 '24 10:03 Snipy7374

Ty for the reviews and sorry if this is taking longer than expected, it's my first API feature so i'm quite inexperienced. I still have the same typing (skill) issue at poll.py/PollAnswer#273, should i just type ignore it? It doesn't seem like our fault.

Snipy7374 avatar Apr 25 '24 09:04 Snipy7374

Ty for the reviews and sorry if this is taking longer than expected, it's my first API feature so i'm quite inexperienced.

No worries, it's a pretty substantial feature and this is already really good c: I feel like many of the issues here boil down to the API structure being somewhat weird in the name of extensibility, and avoiding possible breaking changes in the lib while also making things developer-friendly isn't really trivial.

I still have the same typing (skill) issue at poll.py/PollAnswer#273, should i just type ignore it? It doesn't seem like our fault.

Hm, seems that HTTPClient.get_poll_answer_voters should return a {users: List[User]} typeddict?

shiftinv avatar Apr 26 '24 14:04 shiftinv

https://github.com/DisnakeDev/disnake/pull/1176/commits/9f0c8fd2d010d52783f09acc5bf5a0b33bcb1be7 I have updated the docs to reflect the following discord api changes:

discord/discord-api-docs#6956 discord/discord-api-docs#6968 discord/discord-api-docs#6869

Snipy7374 avatar Jul 18 '24 09:07 Snipy7374

Naming suggestions for class members are now welcome 🙏🏻

Snipy7374 avatar Aug 09 '24 15:08 Snipy7374

Implemented

  • discord/discord-api-docs#7090

Snipy7374 avatar Aug 23 '24 07:08 Snipy7374