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,
})]),
});
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 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