zaun_client/bots/
message.rs1use zaun_community_protocol::command::interaction::CreateData;
4use zaun_community_protocol::command::object::{
5 Component, InteractionMetadata, InteractionType, flags,
6};
7use zaun_community_protocol::ids::InteractionId;
8
9use crate::error::Result;
10use crate::objects::Message;
11
12impl Message {
13 #[must_use]
15 pub fn components(&self) -> &[Component] {
16 &self.components
17 }
18
19 #[must_use]
21 pub const fn flags(&self) -> u32 {
22 self.flags
23 }
24
25 #[must_use]
27 pub const fn is_loading(&self) -> bool {
28 self.flags & flags::LOADING != 0
29 }
30
31 #[must_use]
33 pub const fn interaction(&self) -> Option<&InteractionMetadata> {
34 self.interaction.as_ref()
35 }
36
37 pub fn click(&self, custom_id: &str, values: Vec<String>) -> Result<InteractionId> {
42 let data = CreateData::Component {
43 message_id: self.id,
44 custom_id: custom_id.to_owned(),
45 values,
46 };
47 let created: zaun_community_protocol::command::interaction::Created =
48 self.channel.community.client.command(
49 self.channel.community.id,
50 Some(self.channel.id),
51 zaun_community_protocol::command::interaction::Create {
52 kind: InteractionType::MessageComponent,
53 data,
54 },
55 )?;
56 Ok(created.interaction_id)
57 }
58}