Repository: hikari-py/hikari
Pull request #2265 (2025-03-28 09:38:27)

feat: support for poll parameter in utility methods
### Summary
See pr title 🗿 

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/hikari/interactions/base_interactions.py b/hikari/interactions/base_interactions.py
index f5916b40..1c94ea49 100644
--- a/hikari/interactions/base_interactions.py
+++ b/hikari/interactions/base_interactions.py
@@ -415,6 +415,7 @@ async def create_initial_response(
         ] = undefined.UNDEFINED,
         embed: undefined.UndefinedNoneOr[embeds_.Embed] = undefined.UNDEFINED,
         embeds: undefined.UndefinedNoneOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
+        poll: undefined.UndefinedOr[special_endpoints.PollBuilder] = undefined.UNDEFINED,
         mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
         user_mentions: undefined.UndefinedOr[
             typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
@@ -459,6 +460,8 @@ async def create_initial_response(
             If provided, the message embed.
         embeds
             If provided, the message embeds.
+        poll
+            If provided, the poll to set on the message.
         flags
             If provided, the message flags this response should have.
 
@@ -524,6 +527,7 @@ async def create_initial_response(
             components=components,
             embed=embed,
             embeds=embeds,
+            poll=poll,
             flags=flags,
             mentions_everyone=mentions_everyone,
             user_mentions=user_mentions,
diff --git a/hikari/messages.py b/hikari/messages.py
index d6eab9d7..ae3fdbbd 100644
--- a/hikari/messages.py
+++ b/hikari/messages.py
@@ -1004,6 +1004,8 @@ async def respond(
             If provided, the message embed.
         embeds
             If provided, the message embeds.
+        poll
+            If provided, the poll to set on the message.
         sticker
             If provided, object or ID of a sticker to send on the message.
 
diff --git a/hikari/webhooks.py b/hikari/webhooks.py
index 2e31ed3e..5be22c0e 100644
--- a/hikari/webhooks.py
+++ b/hikari/webhooks.py
@@ -108,6 +108,7 @@ async def execute(
         components: undefined.UndefinedOr[typing.Sequence[special_endpoints.ComponentBuilder]] = undefined.UNDEFINED,
         embed: undefined.UndefinedOr[embeds_.Embed] = undefined.UNDEFINED,
         embeds: undefined.UndefinedOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
+        poll: undefined.UndefinedOr[special_endpoints.PollBuilder] = undefined.UNDEFINED,
         mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
         user_mentions: undefined.UndefinedOr[
             typing.Union[snowflakes.SnowflakeishSequence[users_.PartialUser], bool]
@@ -167,6 +168,8 @@ async def execute(
             If provided, the message embed.
         embeds
             If provided, the message embeds.
+        poll
+            If provided, the poll to set on the message.
         mentions_everyone
             If provided, whether the message should parse @everyone/@here
             mentions.
@@ -228,6 +231,7 @@ async def execute(
             components=components,
             embed=embed,
             embeds=embeds,
+            poll=poll,
             mentions_everyone=mentions_everyone,
             user_mentions=user_mentions,
             role_mentions=role_mentions,


Test patch:
diff --git a/tests/hikari/interactions/test_base_interactions.py b/tests/hikari/interactions/test_base_interactions.py
index 8d1c9a44..6b123eef 100644
--- a/tests/hikari/interactions/test_base_interactions.py
+++ b/tests/hikari/interactions/test_base_interactions.py
@@ -163,6 +163,7 @@ async def test_fetch_initial_response(self, mock_message_response_mixin, mock_ap
     async def test_create_initial_response_with_optional_args(self, mock_message_response_mixin, mock_app):
         mock_embed_1 = object()
         mock_embed_2 = object()
+        mock_poll = object()
         mock_component = object()
         mock_components = object(), object()
         mock_attachment = object()
@@ -174,6 +175,7 @@ async def test_create_initial_response_with_optional_args(self, mock_message_res
             embed=mock_embed_1,
             flags=64,
             embeds=[mock_embed_2],
+            poll=mock_poll,
             component=mock_component,
             components=mock_components,
             attachment=mock_attachment,
@@ -192,6 +194,7 @@ async def test_create_initial_response_with_optional_args(self, mock_message_res
             flags=64,
             embed=mock_embed_1,
             embeds=[mock_embed_2],
+            poll=mock_poll,
             component=mock_component,
             components=mock_components,
             attachment=mock_attachment,
@@ -216,6 +219,7 @@ async def test_create_initial_response_without_optional_args(self, mock_message_
             tts=undefined.UNDEFINED,
             embed=undefined.UNDEFINED,
             embeds=undefined.UNDEFINED,
+            poll=undefined.UNDEFINED,
             component=undefined.UNDEFINED,
             components=undefined.UNDEFINED,
             attachment=undefined.UNDEFINED,
diff --git a/tests/hikari/test_webhooks.py b/tests/hikari/test_webhooks.py
index 29b6dd37..36fe96f7 100644
--- a/tests/hikari/test_webhooks.py
+++ b/tests/hikari/test_webhooks.py
@@ -51,6 +51,7 @@ async def test_execute_with_optionals(self, executable_webhook):
         mock_components = object(), object()
         mock_embed = object()
         mock_embeds = object(), object()
+        mock_poll = object()
 
         result = await executable_webhook.execute(
             content="coooo",
@@ -63,6 +64,7 @@ async def test_execute_with_optionals(self, executable_webhook):
             components=mock_components,
             embed=mock_embed,
             embeds=mock_embeds,
+            poll=mock_poll,
             mentions_everyone=False,
             user_mentions=[1235432],
             role_mentions=[65234123],
@@ -83,6 +85,7 @@ async def test_execute_with_optionals(self, executable_webhook):
             components=mock_components,
             embed=mock_embed,
             embeds=mock_embeds,
+            poll=mock_poll,
             mentions_everyone=False,
             user_mentions=[1235432],
             role_mentions=[65234123],
@@ -107,6 +110,7 @@ async def test_execute_without_optionals(self, executable_webhook):
             components=undefined.UNDEFINED,
             embed=undefined.UNDEFINED,
             embeds=undefined.UNDEFINED,
+            poll=undefined.UNDEFINED,
             mentions_everyone=undefined.UNDEFINED,
             user_mentions=undefined.UNDEFINED,
             role_mentions=undefined.UNDEFINED,