pub struct InteractionResponseDataBuilder(/* private fields */);
Available on crate feature
builder
only.Expand description
Create an InteractionResponseData
with a builder.
§Example
use twilight_model::channel::message::{
component::{ActionRow, Button, ButtonStyle, Component},
MessageFlags,
};
use twilight_util::builder::InteractionResponseDataBuilder;
let component = Component::ActionRow(ActionRow {
components: Vec::from([Component::Button(Button {
style: ButtonStyle::Primary,
emoji: None,
label: Some("Button label".to_string()),
custom_id: Some("button_id".to_string()),
url: None,
disabled: false,
sku_id: None,
})]),
});
let interaction_response_data = InteractionResponseDataBuilder::new()
.content("Callback message")
.flags(MessageFlags::EPHEMERAL)
.components([component.clone()])
.build();
assert_eq!(interaction_response_data.components, Some(vec![component]));
Implementations§
Source§impl InteractionResponseDataBuilder
impl InteractionResponseDataBuilder
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new builder to construct an InteractionResponseData
.
Sourcepub fn build(self) -> InteractionResponseData
pub fn build(self) -> InteractionResponseData
Consume the builder, returning an InteractionResponseData
.
Sourcepub fn allowed_mentions(self, allowed_mentions: AllowedMentions) -> Self
pub fn allowed_mentions(self, allowed_mentions: AllowedMentions) -> Self
Set the AllowedMentions
of the callback.
Defaults to None
.
Sourcepub fn attachments(
self,
attachments: impl IntoIterator<Item = Attachment>,
) -> Self
pub fn attachments( self, attachments: impl IntoIterator<Item = Attachment>, ) -> Self
Set the attachments of the message.
Defaults to None
.
Sourcepub fn choices(
self,
choices: impl IntoIterator<Item = CommandOptionChoice>,
) -> Self
pub fn choices( self, choices: impl IntoIterator<Item = CommandOptionChoice>, ) -> Self
Set the autocomplete choices of the response.
Only valid when the type of the interaction is
ApplicationCommandAutocompleteResult
.
Sourcepub fn components(self, components: impl IntoIterator<Item = Component>) -> Self
pub fn components(self, components: impl IntoIterator<Item = Component>) -> Self
Sourcepub fn content(self, content: impl Into<String>) -> Self
pub fn content(self, content: impl Into<String>) -> Self
Set the message content of the callback.
Defaults to None
.
Sourcepub fn custom_id(self, custom_id: impl Into<String>) -> Self
pub fn custom_id(self, custom_id: impl Into<String>) -> Self
Set the custom ID of the callback.
Defaults to None
.
Sourcepub fn embeds(self, embeds: impl IntoIterator<Item = Embed>) -> Self
pub fn embeds(self, embeds: impl IntoIterator<Item = Embed>) -> Self
Set the Embed
s of the callback.
Defaults to an empty list.
Sourcepub const fn flags(self, flags: MessageFlags) -> Self
pub const fn flags(self, flags: MessageFlags) -> Self
Trait Implementations§
Source§impl Clone for InteractionResponseDataBuilder
impl Clone for InteractionResponseDataBuilder
Source§fn clone(&self) -> InteractionResponseDataBuilder
fn clone(&self) -> InteractionResponseDataBuilder
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for InteractionResponseDataBuilder
impl RefUnwindSafe for InteractionResponseDataBuilder
impl Send for InteractionResponseDataBuilder
impl Sync for InteractionResponseDataBuilder
impl Unpin for InteractionResponseDataBuilder
impl UnwindSafe for InteractionResponseDataBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more