titanium_http/
interaction.rs1use crate::error::HttpError;
2use crate::HttpClient;
3use serde::Serialize;
4use titanium_model::{InteractionResponse, Message, Snowflake};
5
6impl HttpClient {
7 pub async fn create_interaction_response(
12 &self,
13 interaction_id: Snowflake,
14 token: &str,
15 response: &InteractionResponse<'_>,
16 ) -> Result<(), HttpError> {
17 let route = format!("/interactions/{}/{}/callback", interaction_id, token);
18 self.post(&route, response).await
19 }
20
21 pub async fn get_original_interaction_response(
23 &self,
24 application_id: Snowflake,
25 token: &str,
26 ) -> Result<Message<'static>, HttpError> {
27 let route = format!("/webhooks/{}/{}/messages/@original", application_id, token);
28 self.get(&route).await
29 }
30
31 pub async fn edit_original_interaction_response<B: Serialize>(
35 &self,
36 application_id: Snowflake,
37 token: &str,
38 body: B,
39 ) -> Result<Message<'static>, HttpError> {
40 let route = format!("/webhooks/{}/{}/messages/@original", application_id, token);
41 self.patch(&route, body).await
42 }
43
44 pub async fn delete_original_interaction_response(
46 &self,
47 application_id: Snowflake,
48 token: &str,
49 ) -> Result<(), HttpError> {
50 let route = format!("/webhooks/{}/{}/messages/@original", application_id, token);
51 self.delete(&route).await
52 }
53
54 pub async fn create_followup_message<B: Serialize>(
58 &self,
59 application_id: Snowflake,
60 token: &str,
61 body: B,
62 ) -> Result<Message<'static>, HttpError> {
63 let route = format!("/webhooks/{}/{}", application_id, token);
64 self.post_with_query(&route, body, &[("wait", "true")])
66 .await
67 }
68}