Skip to content

Commit 1b4a3ff

Browse files
authored
Add polls to interaction responses (#3013)
1 parent e14acaf commit 1b4a3ff

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/builder/create_interaction_response.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use super::create_poll::Ready;
12
#[cfg(feature = "http")]
23
use super::{check_overflow, Builder};
34
use super::{
45
CreateActionRow,
56
CreateAllowedMentions,
67
CreateAttachment,
78
CreateEmbed,
9+
CreatePoll,
810
EditAttachments,
911
};
1012
#[cfg(feature = "http")]
@@ -179,6 +181,8 @@ pub struct CreateInteractionResponseMessage {
179181
flags: Option<InteractionResponseFlags>,
180182
#[serde(skip_serializing_if = "Option::is_none")]
181183
components: Option<Vec<CreateActionRow>>,
184+
#[serde(skip_serializing_if = "Option::is_none")]
185+
poll: Option<CreatePoll<Ready>>,
182186
attachments: EditAttachments,
183187
}
184188

@@ -294,6 +298,15 @@ impl CreateInteractionResponseMessage {
294298
self.components = Some(components);
295299
self
296300
}
301+
302+
/// Adds a poll to the message. Only one poll can be added per message.
303+
///
304+
/// See [`CreatePoll`] for more information on creating and configuring a poll.
305+
pub fn poll(mut self, poll: CreatePoll<Ready>) -> Self {
306+
self.poll = Some(poll);
307+
self
308+
}
309+
297310
super::button_and_select_menu_convenience_methods!(self.components);
298311
}
299312

src/builder/create_interaction_response_followup.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use super::create_poll::Ready;
12
#[cfg(feature = "http")]
23
use super::{check_overflow, Builder};
34
use super::{
45
CreateActionRow,
56
CreateAllowedMentions,
67
CreateAttachment,
78
CreateEmbed,
9+
CreatePoll,
810
EditAttachments,
911
};
1012
#[cfg(feature = "http")]
@@ -32,6 +34,8 @@ pub struct CreateInteractionResponseFollowup {
3234
components: Option<Vec<CreateActionRow>>,
3335
#[serde(skip_serializing_if = "Option::is_none")]
3436
flags: Option<MessageFlags>,
37+
#[serde(skip_serializing_if = "Option::is_none")]
38+
poll: Option<CreatePoll<Ready>>,
3539
attachments: EditAttachments,
3640
}
3741

@@ -154,6 +158,14 @@ impl CreateInteractionResponseFollowup {
154158
self
155159
}
156160

161+
/// Adds a poll to the message. Only one poll can be added per message.
162+
///
163+
/// See [`CreatePoll`] for more information on creating and configuring a poll.
164+
pub fn poll(mut self, poll: CreatePoll<Ready>) -> Self {
165+
self.poll = Some(poll);
166+
self
167+
}
168+
157169
/// Sets the components of this message.
158170
pub fn components(mut self, components: Vec<CreateActionRow>) -> Self {
159171
self.components = Some(components);

0 commit comments

Comments
 (0)