diff --git a/src/reply/builder.rs b/src/reply/builder.rs index a4d94df6309a..3e52fdebc2b8 100644 --- a/src/reply/builder.rs +++ b/src/reply/builder.rs @@ -17,6 +17,8 @@ pub struct CreateReply { pub components: Option>, /// The allowed mentions for the message. pub allowed_mentions: Option, + /// Message poll, if present. + poll: Option>, /// Whether this message is an inline reply. pub reply: bool, #[doc(hidden)] @@ -68,6 +70,17 @@ impl CreateReply { self } + /// Adds a poll to the message. Only one poll can be added per message. + /// + /// See [`serenity::CreatePoll`] for more information on creating and configuring a poll. + pub fn poll( + mut self, + poll: serenity::CreatePoll, + ) -> Self { + self.poll = Some(poll); + self + } + /// Makes this message an inline reply to another message like [`serenity::Message::reply`] /// (prefix-only, because slash commands are always inline replies anyways). /// @@ -94,6 +107,7 @@ impl CreateReply { components, ephemeral, allowed_mentions, + poll, reply: _, // can't reply to a message in interactions __non_exhaustive: (), } = self; @@ -110,6 +124,9 @@ impl CreateReply { if let Some(ephemeral) = ephemeral { builder = builder.ephemeral(ephemeral); } + if let Some(poll) = poll { + builder = builder.poll(poll); + } builder.add_files(attachments).embeds(embeds) } @@ -126,6 +143,7 @@ impl CreateReply { components, ephemeral, allowed_mentions, + poll, reply: _, __non_exhaustive: (), } = self; @@ -143,6 +161,9 @@ impl CreateReply { if let Some(ephemeral) = ephemeral { builder = builder.ephemeral(ephemeral); } + if let Some(poll) = poll { + builder = builder.poll(poll); + } builder.add_files(attachments) } @@ -159,6 +180,7 @@ impl CreateReply { components, ephemeral: _, // can't edit ephemerality in retrospect allowed_mentions, + poll, reply: _, __non_exhaustive: (), } = self; @@ -175,6 +197,9 @@ impl CreateReply { for attachment in attachments { builder = builder.new_attachment(attachment); } + if let Some(poll) = poll { + builder = builder.poll(poll); + } builder.embeds(embeds) } @@ -188,6 +213,7 @@ impl CreateReply { components, ephemeral: _, // not supported in prefix allowed_mentions, + poll, reply: _, // can't edit reference message afterwards __non_exhaustive: (), } = self; @@ -206,6 +232,9 @@ impl CreateReply { if let Some(components) = components { builder = builder.components(components); } + if let Some(poll) = poll { + builder = builder.poll(poll); + } builder.embeds(embeds).attachments(attachments_builder) } @@ -222,6 +251,7 @@ impl CreateReply { components, ephemeral: _, // not supported in prefix allowed_mentions, + poll, reply, __non_exhaustive: (), } = self; @@ -239,6 +269,9 @@ impl CreateReply { if reply { builder = builder.reference_message(invocation_message); } + if let Some(poll) = poll { + builder = builder.poll(poll); + } for attachment in attachments { builder = builder.add_file(attachment);