Add support for Polls

Co-authored-by: owocado <24418520+owocado@users.noreply.github.com>
Co-authored-by: Josh <8677174+bijij@users.noreply.github.com>
Co-authored-by: Trevor Flahardy <75498301+trevorflahardy@users.noreply.github.com>
This commit is contained in:
DA344
2024-05-10 12:14:12 +02:00
committed by GitHub
parent a1206dfde8
commit e43bd8692c
19 changed files with 1097 additions and 1 deletions

View File

@ -1047,6 +1047,42 @@ Messages
:param payload: The raw event payload data.
:type payload: :class:`RawBulkMessageDeleteEvent`
Polls
~~~~~~
.. function:: on_poll_vote_add(user, answer)
on_poll_vote_remove(user, answer)
Called when a :class:`Poll` gains or loses a vote. If the ``user`` or ``message``
are not cached then this event will not be called.
This requires :attr:`Intents.message_content` and :attr:`Intents.polls` to be enabled.
.. note::
If the poll allows multiple answers and the user removes or adds multiple votes, this
event will be called as many times as votes that are added or removed.
.. versionadded:: 2.4
:param user: The user that performed the action.
:type user: Union[:class:`User`, :class:`Member`]
:param answer: The answer the user voted or removed their vote from.
:type answer: :class:`PollAnswer`
.. function:: on_raw_poll_vote_add(payload)
on_raw_poll_vote_remove(payload)
Called when a :class:`Poll` gains or loses a vote. Unlike :func:`on_poll_vote_add` and :func:`on_poll_vote_remove`
this is called regardless of the state of the internal user and message cache.
This requires :attr:`Intents.message_content` and :attr:`Intents.polls` to be enabled.
.. versionadded:: 2.4
:param payload: The raw event payload data.
:type payload: :class:`RawPollVoteActionEvent`
Reactions
~~~~~~~~~~
@ -3577,6 +3613,16 @@ of :class:`enum.Enum`.
The entitlement owner is a user.
.. class:: PollLayoutType
Represents how a poll answers are shown
.. versionadded:: 2.4
.. attribute:: default
The default layout.
.. _discord-api-audit-logs:
Audit Log Data
@ -5007,6 +5053,14 @@ RawAppCommandPermissionsUpdateEvent
.. autoclass:: RawAppCommandPermissionsUpdateEvent()
:members:
RawPollVoteActionEvent
~~~~~~~~~~~~~~~~~~~~~~
.. attributetable:: RawPollVoteActionEvent
.. autoclass:: RawPollVoteActionEvent()
:members:
PartialWebhookGuild
~~~~~~~~~~~~~~~~~~~~
@ -5288,6 +5342,25 @@ ForumTag
.. autoclass:: ForumTag
:members:
Poll
~~~~
.. attributetable:: Poll
.. autoclass:: Poll()
:members:
.. attributetable:: PollAnswer
.. autoclass:: PollAnswer()
:members:
:inherited-members:
.. attributetable:: PollMedia
.. autoclass:: PollMedia()
:members:
Exceptions
------------