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

Document polls. #6746

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Document polls. #6746

merged 1 commit into from
Apr 18, 2024

Conversation

tpcstld
Copy link
Contributor

@tpcstld tpcstld commented Mar 21, 2024

Summary

Polls!

Hey folks, Discord plans to add first-party support for polls. The feature has started it's old good experimentation phase today, so now's about the time to document it as well. We expect that bots will be able to create these first-party polls when they become available. As usual this is subject to change yadda yadda no guarentees yadda yadda, but I personally I don't expect any changes.

However... some things are still being implemented right now for bots:

  1. We will have a separate gateway intent for poll votes, currently it's backpacking upon the reactions intent, but there will be a new one!
  2. Currently content, components and a variety of other fields are not able to be sent alongside the poll field.
  3. A kind of corollary of (2), but you can't edit a message that has a poll right now either. You won't be able to edit a poll's data anyways in the future for now, but you will be able to edit everything else (like content) after (2) is done.

Most of this stuff will be done next week, after people are back from GDC. :)

Anyways cheers. I probably got some stuff wrong in this documentation so I look forward to the online community telling me that :)

@Misha-133
Copy link
Contributor

Misha-133 commented Mar 21, 2024

Probably should mention answers limit (10 answers per poll)

@Lulalaby
Copy link
Contributor

Lulalaby commented Mar 21, 2024

Can guilds with BOT_DEVELOPER_EARLY_ACCESS get access to test implementations?

docs/resources/Poll.md Outdated Show resolved Hide resolved
docs/resources/Poll.md Outdated Show resolved Hide resolved
@tpcstld
Copy link
Contributor Author

tpcstld commented Mar 21, 2024

Can guilds with BOT_DEVELOPER_EARLY_ACCESS get access to test implementations?

Should be done now.

@sebm253 sebm253 mentioned this pull request Mar 21, 2024
6 tasks
@sebm253
Copy link
Contributor

sebm253 commented Mar 21, 2024

it seems like this version of the documentation is missing the duration field when creating polls. creation could use some clarification as well :-)

@Lulalaby
Copy link
Contributor

Thank you, works!

docs/resources/Poll.md Outdated Show resolved Hide resolved
docs/resources/Poll.md Show resolved Hide resolved
docs/resources/Poll.md Show resolved Hide resolved
docs/resources/Poll.md Outdated Show resolved Hide resolved
@KiterWork
Copy link

Create a seperate permission node so the communities we are in won't just spam a gazillion polls?

docs/resources/Poll.md Outdated Show resolved Hide resolved
docs/resources/Poll.md Outdated Show resolved Hide resolved
@almeidx
Copy link
Contributor

almeidx commented Mar 22, 2024

Is it intended that results.answer_counts is always empty when retrieved from the Get Channel Message endpoint for ongoing polls?
The Get Channel Messages endpoint returns the correct answer count data

docs/resources/Poll.md Show resolved Hide resolved
docs/resources/Poll.md Outdated Show resolved Hide resolved
docs/topics/Opcodes_and_Status_Codes.md Show resolved Hide resolved
@tpcstld
Copy link
Contributor Author

tpcstld commented Mar 23, 2024

Is it intended that results.answer_counts is always empty when retrieved from the Get Channel Message endpoint for ongoing polls? The Get Channel Messages endpoint returns the correct answer count data

No. Thanks for catching this. Might be a little while until we fix this though as we're heading into the weekend. :(

| expiry | IS08601 timestamp | The time when the poll ends. |
| allow_multiselect | boolean | Whether a user can select multiple answers |
| layout_type | integer | The [layout type](#DOCS_RESOURCES_POLL/layout-type) of the poll |
| results | [Poll Results Object](#DOCS_RESOURCES_POLL/poll-results-object-poll-results-object-structure) | The results of the poll |
Copy link
Contributor

@DonovanDMC DonovanDMC Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results seems to be nullable only for messages received over a gateway connection, I've yet to see it null over rest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our intention is that it should be always non-null (with just... default values for polls without votes yet). Are you still seeing it null through the Gateway? I'm going to check later just wondering if anyone knows right now. :P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I can still reproduce it

@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 16, 2024

A quick question, can webhook started polls be pre-expired (like, end them before the poll closes automatically)?

We're unlikely to support this. :( If you need to manually end your polls, create a bot so it can own the polls.

@budgetdevv
Copy link

budgetdevv commented Apr 17, 2024

Another question: Would it be possible to re-open polls ( Via API or otherwise ) ? For instance, when they expire after a week

@DA-344
Copy link

DA-344 commented Apr 17, 2024

Discord has announced a Create Polls permission or similar, they are going to be documented, right? 😅

@jhgg
Copy link
Contributor

jhgg commented Apr 17, 2024

Another question: Would it be possible to re-open polls ( Via API or otherwise ) ? For instance, when they expire after a week

No, polls closing is a final state.

Discord has announced a Create Polls permission or similar, they are going to be documented, right? 😅

Yes.

@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 17, 2024

it is also empty in GET /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}

This endpoint will start including both reactions and poll results.

But actually I've been thinking about my decision in #6746 (comment) and I actually think it's better for the future if results is nullable for gateway events and maybe some API endpoints. There is a certain amount of complexity for getting results for the gateway event that I feel should probably not be tackled, just like how reactions are not always returned for the message. I will update the documentation to reflect this and I'll probably make the field missing instead of it returning null.

Done: These are things that should have some semblence of stability.
* Document model
* Document gateway events
* Document endpoints.
* Abort errors.
@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 17, 2024

In case you missed it, this newest update to the docs includes the SEND_POLLS permission. Client support is still rolling out for it (like graying it out) but it should be done in at most a few hours :)

I believe that I have resolved all outstanding issues. If nothing bad comes up, this PR will be merged by EOD.

@NeloBlivion
Copy link

Does a poll naturally "expiring" also fire a MESSAGE_UPDATE event, or is this only when someone manually ends it?

@FozzieHi
Copy link

FozzieHi commented Apr 17, 2024

Does a poll naturally "expiring" also fire a MESSAGE_UPDATE event, or is this only when someone manually ends it?

I believe it does from what I have seen myself (to be clear, I don't work for Discord so I don't know for certain).

@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 17, 2024

Does a poll naturally "expiring" also fire a MESSAGE_UPDATE event, or is this only when someone manually ends it?

Yes, specifically it is sent right now when the poll finishes counting the votes. :)

@NeloBlivion
Copy link

Final issue i've found, sending content and embeds with polls works fine but it seems attachments collide with undocumented poll features; could this be disabled for now, or are we meant to implement compatibility...?
Specifically, 50035 Invalid Form Body - In poll: Poll attachment_ids must correspond with attachments data

@MCausc78
Copy link
Contributor

Final issue i've found, sending content and embeds with polls works fine but it seems attachments collide with undocumented poll features; could this be disabled for now, or are we meant to implement compatibility...?
Specifically, 50035 Invalid Form Body - In poll: Poll attachment_ids must correspond with attachments data

Yes, there was PollLayoutType.IMAGE_ONLY_ANSWERS with value 2 available, probably that.

@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 18, 2024

Final issue i've found, sending content and embeds with polls works fine but it seems attachments collide with undocumented poll features; could this be disabled for now, or are we meant to implement compatibility...?

For now you're not able to have attachments with the poll, sorry. :P

@tpcstld tpcstld merged commit df7d365 into main Apr 18, 2024
6 checks passed
@tpcstld tpcstld deleted the polls branch April 18, 2024 18:13
@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 18, 2024

I said EOD but got distracted. :P

@GeniusTimo
Copy link
Contributor

Will there be an addition to the change log with information about this new feature in the future?

DonovanDMC added a commit to OceanicJS/Oceanic that referenced this pull request Apr 18, 2024
@Lulalaby
Copy link
Contributor

Not sure if this is a bug but the results object behaves weird

If the poll is open, it returns only the till not selected options in answer_counts:
image

If the poll gets closed with /expire, the answer_counts object is empty and the is_finalized is still false:
image

If the message gets re-fetched, it's correct:
image

Is that a bug or expected behavior due to the polls implementation or something?

@tpcstld
Copy link
Contributor Author

tpcstld commented Apr 22, 2024

@Lulalaby I think you're saying that the message returned from the /expire endpoint has empty results right? I will fix this. This is a bug.

Please note that is_finalized will still probably be false though, as the counting happens in a background job that does not block the endpoint. The non-finalized results are probably fine for most applications though.

@Lulalaby
Copy link
Contributor

yeah, thank you

shaydewael pushed a commit to Jupith/discord-api-docs that referenced this pull request May 14, 2024
@budgetdevv
Copy link

Anyone able to reproduce MESSAGE_UPDATE not sending a poll result with is_finalized = true after a poll expires?

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.