Skip to content

Commit 316cff0

Browse files
committed
feat: add polls to send functions
1 parent 9561e56 commit 316cff0

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

interactions/client/mixins/send.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from interactions.models.discord.components import BaseComponent
1111
from interactions.models.discord.embed import Embed
1212
from interactions.models.discord.message import AllowedMentions, Message, MessageReference
13+
from interactions.models.discord.poll import Poll
1314
from interactions.models.discord.sticker import Sticker
1415
from interactions.models.discord.snowflake import Snowflake_Type
1516

@@ -49,6 +50,7 @@ async def send(
4950
delete_after: Optional[float] = None,
5051
nonce: Optional[str | int] = None,
5152
enforce_nonce: bool = False,
53+
poll: "Optional[Poll | dict]" = None,
5254
**kwargs: Any,
5355
) -> "Message":
5456
"""
@@ -73,6 +75,7 @@ async def send(
7375
enforce_nonce: If enabled and nonce is present, it will be checked for uniqueness in the past few minutes. \
7476
If another message was created by the same author with the same nonce, that message will be returned \
7577
and no new message will be created.
78+
poll: A poll.
7679
7780
Returns:
7881
New message object that was sent.
@@ -115,6 +118,7 @@ async def send(
115118
flags=flags,
116119
nonce=nonce,
117120
enforce_nonce=enforce_nonce,
121+
poll=poll,
118122
**kwargs,
119123
)
120124

interactions/ext/hybrid_commands/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Attachment,
2424
process_message_payload,
2525
TYPE_MESSAGEABLE_CHANNEL,
26+
Poll,
2627
)
2728
from interactions.models.discord.enums import ContextType
2829
from interactions.client.mixins.send import SendMixin
@@ -309,6 +310,7 @@ async def send(
309310
suppress_embeds: bool = False,
310311
silent: bool = False,
311312
flags: Optional[Union[int, "MessageFlags"]] = None,
313+
poll: "Optional[Poll | dict]" = None,
312314
delete_after: Optional[float] = None,
313315
ephemeral: bool = False,
314316
**kwargs: Any,
@@ -330,6 +332,7 @@ async def send(
330332
suppress_embeds: Should embeds be suppressed on this send
331333
silent: Should this message be sent without triggering a notification.
332334
flags: Message flags to apply.
335+
poll: A poll.
333336
delete_after: Delete message after this many seconds.
334337
ephemeral: Should this message be sent as ephemeral (hidden) - only works with interactions
335338
@@ -358,6 +361,7 @@ async def send(
358361
file=file,
359362
tts=tts,
360363
flags=flags,
364+
poll=poll,
361365
delete_after=delete_after,
362366
pass_self_into_delete=bool(self._slash_ctx),
363367
**kwargs,

interactions/models/discord/message.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from interactions.models.discord.embed import process_embeds
2929
from interactions.models.discord.emoji import process_emoji_req_format
3030
from interactions.models.discord.file import UPLOADABLE_TYPE
31+
from interactions.models.discord.poll import Poll
3132

3233
from .base import DiscordObject
3334
from .enums import (
@@ -981,6 +982,7 @@ def process_message_payload(
981982
flags: Optional[Union[int, MessageFlags]] = None,
982983
nonce: Optional[str | int] = None,
983984
enforce_nonce: bool = False,
985+
poll: Optional[Poll | dict] = None,
984986
**kwargs,
985987
) -> dict:
986988
"""
@@ -1000,6 +1002,7 @@ def process_message_payload(
10001002
enforce_nonce: If enabled and nonce is present, it will be checked for uniqueness in the past few minutes. \
10011003
If another message was created by the same author with the same nonce, that message will be returned \
10021004
and no new message will be created.
1005+
poll: A poll.
10031006
10041007
Returns:
10051008
Dictionary
@@ -1017,6 +1020,9 @@ def process_message_payload(
10171020
if attachments:
10181021
attachments = [attachment.to_dict() for attachment in attachments]
10191022

1023+
if isinstance(poll, Poll):
1024+
poll = poll.to_dict()
1025+
10201026
return dict_filter_none(
10211027
{
10221028
"content": content,
@@ -1030,6 +1036,7 @@ def process_message_payload(
10301036
"flags": flags,
10311037
"nonce": nonce,
10321038
"enforce_nonce": enforce_nonce,
1039+
"poll": poll,
10331040
**kwargs,
10341041
}
10351042
)

interactions/models/discord/webhooks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
Message,
2828
MessageReference,
2929
)
30+
from interactions.models.discord.poll import Poll
3031
from interactions.models.discord.sticker import Sticker
3132

3233
__all__ = ("WebhookTypes", "Webhook")
@@ -190,6 +191,7 @@ async def send(
190191
tts: bool = False,
191192
suppress_embeds: bool = False,
192193
flags: Optional[Union[int, "MessageFlags"]] = None,
194+
poll: "Optional[Poll | dict]" = None,
193195
username: str | None = None,
194196
avatar_url: str | None = None,
195197
wait: bool = False,
@@ -212,6 +214,7 @@ async def send(
212214
tts: Should this message use Text To Speech.
213215
suppress_embeds: Should embeds be suppressed on this send
214216
flags: Message flags to apply.
217+
poll: A poll.
215218
username: The username to use
216219
avatar_url: The url of an image to use as the avatar
217220
wait: Waits for confirmation of delivery. Set this to True if you intend to edit the message
@@ -241,6 +244,7 @@ async def send(
241244
reply_to=reply_to,
242245
tts=tts,
243246
flags=flags,
247+
poll=poll,
244248
username=username,
245249
avatar_url=avatar_url,
246250
**kwargs,

interactions/models/internal/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from interactions.client.const import get_logger, MISSING
1313
from interactions.models.discord.components import BaseComponent
1414
from interactions.models.discord.file import UPLOADABLE_TYPE
15+
from interactions.models.discord.poll import Poll
1516
from interactions.models.discord.sticker import Sticker
1617
from interactions.models.discord.user import Member, User
1718

@@ -540,6 +541,7 @@ async def send(
540541
suppress_embeds: bool = False,
541542
silent: bool = False,
542543
flags: typing.Optional[typing.Union[int, "MessageFlags"]] = None,
544+
poll: "typing.Optional[Poll | dict]" = None,
543545
delete_after: typing.Optional[float] = None,
544546
ephemeral: bool = False,
545547
**kwargs: typing.Any,
@@ -561,6 +563,7 @@ async def send(
561563
suppress_embeds: Should embeds be suppressed on this send
562564
silent: Should this message be sent without triggering a notification.
563565
flags: Message flags to apply.
566+
poll: A poll.
564567
delete_after: Delete message after this many seconds.
565568
ephemeral: Whether the response should be ephemeral
566569
@@ -589,6 +592,7 @@ async def send(
589592
file=file,
590593
tts=tts,
591594
flags=flags,
595+
poll=poll,
592596
delete_after=delete_after,
593597
pass_self_into_delete=True,
594598
**kwargs,

0 commit comments

Comments
 (0)