mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-07 10:22:59 +00:00
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:
@ -49,6 +49,7 @@ if TYPE_CHECKING:
|
||||
ThreadMembersUpdate,
|
||||
TypingStartEvent,
|
||||
GuildMemberRemoveEvent,
|
||||
PollVoteActionEvent,
|
||||
)
|
||||
from .types.command import GuildApplicationCommandPermissions
|
||||
from .message import Message
|
||||
@ -77,6 +78,7 @@ __all__ = (
|
||||
'RawTypingEvent',
|
||||
'RawMemberRemoveEvent',
|
||||
'RawAppCommandPermissionsUpdateEvent',
|
||||
'RawPollVoteActionEvent',
|
||||
)
|
||||
|
||||
|
||||
@ -519,3 +521,33 @@ class RawAppCommandPermissionsUpdateEvent(_RawReprMixin):
|
||||
self.permissions: List[AppCommandPermissions] = [
|
||||
AppCommandPermissions(data=perm, guild=self.guild, state=state) for perm in data['permissions']
|
||||
]
|
||||
|
||||
|
||||
class RawPollVoteActionEvent(_RawReprMixin):
|
||||
"""Represents the payload for a :func:`on_raw_poll_vote_add` or :func:`on_raw_poll_vote_remove`
|
||||
event.
|
||||
|
||||
.. versionadded:: 2.4
|
||||
|
||||
Attributes
|
||||
----------
|
||||
user_id: :class:`int`
|
||||
The ID of the user that added or removed a vote.
|
||||
channel_id: :class:`int`
|
||||
The channel ID where the poll vote action took place.
|
||||
message_id: :class:`int`
|
||||
The message ID that contains the poll the user added or removed their vote on.
|
||||
guild_id: Optional[:class:`int`]
|
||||
The guild ID where the vote got added or removed, if applicable..
|
||||
answer_id: :class:`int`
|
||||
The poll answer's ID the user voted on.
|
||||
"""
|
||||
|
||||
__slots__ = ('user_id', 'channel_id', 'message_id', 'guild_id', 'answer_id')
|
||||
|
||||
def __init__(self, data: PollVoteActionEvent) -> None:
|
||||
self.user_id: int = int(data['user_id'])
|
||||
self.channel_id: int = int(data['channel_id'])
|
||||
self.message_id: int = int(data['message_id'])
|
||||
self.guild_id: Optional[int] = _get_as_snowflake(data, 'guild_id')
|
||||
self.answer_id: int = int(data['answer_id'])
|
||||
|
Reference in New Issue
Block a user