serenity/builder/
edit_interaction_response.rs1#[cfg(feature = "http")]
2use super::Builder;
3use super::{
4 CreateActionRow,
5 CreateAllowedMentions,
6 CreateAttachment,
7 CreateEmbed,
8 EditAttachments,
9 EditWebhookMessage,
10};
11#[cfg(feature = "http")]
12use crate::http::CacheHttp;
13#[cfg(feature = "http")]
14use crate::internal::prelude::*;
15use crate::model::prelude::*;
16
17#[derive(Clone, Debug, Default, Serialize)]
19#[must_use]
20pub struct EditInteractionResponse(EditWebhookMessage);
21
22impl EditInteractionResponse {
23 pub fn new() -> Self {
25 Self::default()
26 }
27
28 #[inline]
32 pub fn content(self, content: impl Into<String>) -> Self {
33 Self(self.0.content(content))
34 }
35
36 pub fn add_embed(self, embed: CreateEmbed) -> Self {
40 Self(self.0.add_embed(embed))
41 }
42
43 pub fn add_embeds(self, embeds: Vec<CreateEmbed>) -> Self {
47 Self(self.0.add_embeds(embeds))
48 }
49
50 pub fn embed(self, embed: CreateEmbed) -> Self {
55 Self(self.0.embed(embed))
56 }
57
58 pub fn embeds(self, embeds: Vec<CreateEmbed>) -> Self {
65 Self(self.0.embeds(embeds))
66 }
67
68 pub fn allowed_mentions(self, allowed_mentions: CreateAllowedMentions) -> Self {
70 Self(self.0.allowed_mentions(allowed_mentions))
71 }
72
73 pub fn components(self, components: Vec<CreateActionRow>) -> Self {
75 Self(self.0.components(components))
76 }
77 super::button_and_select_menu_convenience_methods!(self.0.components);
78
79 pub fn flags(self, flags: MessageFlags) -> Self {
81 Self(self.0.flags(flags))
82 }
83
84 pub fn attachments(self, attachments: EditAttachments) -> Self {
86 Self(self.0.attachments(attachments))
87 }
88
89 pub fn new_attachment(self, attachment: CreateAttachment) -> Self {
93 Self(self.0.new_attachment(attachment))
94 }
95
96 pub fn keep_existing_attachment(self, id: AttachmentId) -> Self {
98 Self(self.0.keep_existing_attachment(id))
99 }
100
101 pub fn clear_attachments(self) -> Self {
103 Self(self.0.clear_attachments())
104 }
105}
106
107#[cfg(feature = "http")]
108#[async_trait::async_trait]
109impl Builder for EditInteractionResponse {
110 type Context<'ctx> = &'ctx str;
111 type Built = Message;
112
113 async fn execute(
127 mut self,
128 cache_http: impl CacheHttp,
129 ctx: Self::Context<'_>,
130 ) -> Result<Self::Built> {
131 self.0.check_length()?;
132
133 let files = self.0.attachments.as_mut().map_or(Vec::new(), |a| a.take_files());
134
135 cache_http.http().edit_original_interaction_response(ctx, &self, files).await
136 }
137}