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

@ -92,6 +92,7 @@ if TYPE_CHECKING:
VoiceChannel,
StageChannel,
)
from .poll import Poll
from .threads import Thread
from .ui.view import View
from .types.channel import (
@ -1350,6 +1351,7 @@ class Messageable:
view: View = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
) -> Message:
...
@ -1370,6 +1372,7 @@ class Messageable:
view: View = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
) -> Message:
...
@ -1390,6 +1393,7 @@ class Messageable:
view: View = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
) -> Message:
...
@ -1410,6 +1414,7 @@ class Messageable:
view: View = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
) -> Message:
...
@ -1431,6 +1436,7 @@ class Messageable:
view: Optional[View] = None,
suppress_embeds: bool = False,
silent: bool = False,
poll: Optional[Poll] = None,
) -> Message:
"""|coro|
@ -1516,6 +1522,10 @@ class Messageable:
in the UI, but will not actually send a notification.
.. versionadded:: 2.2
poll: :class:`~discord.Poll`
The poll to send with this message.
.. versionadded:: 2.4
Raises
--------
@ -1582,6 +1592,7 @@ class Messageable:
stickers=sticker_ids,
view=view,
flags=flags,
poll=poll,
) as params:
data = await state.http.send_message(channel.id, params=params)
@ -1589,6 +1600,9 @@ class Messageable:
if view and not view.is_finished():
state.store_view(view, ret.id)
if poll:
poll._update(ret)
if delete_after is not None:
await ret.delete(delay=delete_after)
return ret