polyphony_types/entities/
message.rs1use serde::{Deserialize, Serialize};
2
3use crate::{
4 entities::{
5 Application, Attachment, Channel, Emoji, GuildMember, RoleSubscriptionData, Sticker,
6 StickerItem, User,
7 },
8 utils::Snowflake,
9};
10
11#[derive(Debug, Serialize, Deserialize, Default)]
12pub struct Message {
13 id: Snowflake,
14 pub channel_id: Snowflake,
15 author: User,
16 content: String,
17 timestamp: String,
18 edited_timestamp: Option<String>,
19 tts: bool,
20 mention_everyone: bool,
21 mentions: Vec<User>,
22 mention_roles: Vec<String>,
23 mention_channels: Option<Vec<ChannelMention>>,
24 pub attachments: Vec<Attachment>,
25 embeds: Vec<Embed>,
26 reactions: Option<Vec<Reaction>>,
27 nonce: Option<serde_json::Value>,
28 pinned: bool,
29 webhook_id: Option<String>,
30 #[serde(rename = "type")]
31 message_type: i32,
32 activity: Option<MessageActivity>,
33 application: Option<Application>,
34 application_id: Option<String>,
35 message_reference: Option<MessageReference>,
36 flags: Option<i32>,
37 referenced_message: Option<Box<Message>>,
38 interaction: Option<MessageInteraction>,
39 thread: Option<Channel>,
40 components: Option<Vec<Component>>,
41 sticker_items: Option<Vec<StickerItem>>,
42 stickers: Option<Vec<Sticker>>,
43 position: Option<i32>,
44 role_subscription_data: Option<RoleSubscriptionData>,
45}
46
47#[derive(Debug, Serialize, Deserialize)]
48pub struct MessageReference {
49 pub message_id: Snowflake,
50 pub channel_id: Snowflake,
51 pub guild_id: Option<Snowflake>,
52 pub fail_if_not_exists: Option<bool>,
53}
54
55#[derive(Debug, Deserialize, Serialize)]
56pub struct MessageInteraction {
57 pub id: Snowflake,
58 #[serde(rename = "type")]
59 pub interaction_type: u8,
60 pub name: String,
61 pub user: User,
62 pub member: Option<GuildMember>,
63}
64
65#[derive(Debug, Serialize, Deserialize)]
66pub struct AllowedMention {
67 parse: Vec<AllowedMentionType>,
68 roles: Vec<Snowflake>,
69 users: Vec<Snowflake>,
70 replied_user: bool,
71}
72
73#[derive(Debug, Serialize, Deserialize)]
74#[serde(rename_all = "snake_case")]
75pub enum AllowedMentionType {
76 Roles,
77 Users,
78 Everyone,
79}
80
81#[derive(Debug, Serialize, Deserialize)]
82struct ChannelMention {
83 id: Snowflake,
84 guild_id: Snowflake,
85 #[serde(rename = "type")]
86 channel_type: i32,
87 name: String,
88}
89
90#[derive(Debug, Serialize, Deserialize)]
91pub struct Embed {
92 title: Option<String>,
93 #[serde(rename = "type")]
94 embed_type: Option<String>,
95 description: Option<String>,
96 url: Option<String>,
97 timestamp: Option<String>,
98 color: Option<i32>,
99 footer: Option<EmbedFooter>,
100 image: Option<EmbedImage>,
101 thumbnail: Option<EmbedThumbnail>,
102 video: Option<EmbedVideo>,
103 provider: Option<EmbedProvider>,
104 author: Option<EmbedAuthor>,
105 fields: Option<Vec<EmbedField>>,
106}
107
108#[derive(Debug, Serialize, Deserialize)]
109struct EmbedFooter {
110 text: String,
111 icon_url: Option<String>,
112 proxy_icon_url: Option<String>,
113}
114
115#[derive(Debug, Serialize, Deserialize)]
116struct EmbedImage {
117 url: String,
118 proxy_url: String,
119 height: Option<i32>,
120 width: Option<i32>,
121}
122
123#[derive(Debug, Serialize, Deserialize)]
124struct EmbedThumbnail {
125 url: String,
126 proxy_url: Option<String>,
127 height: Option<i32>,
128 width: Option<i32>,
129}
130
131#[derive(Debug, Serialize, Deserialize)]
132struct EmbedVideo {
133 url: Option<String>,
134 proxy_url: Option<String>,
135 height: Option<i32>,
136 width: Option<i32>,
137}
138
139#[derive(Debug, Serialize, Deserialize)]
140struct EmbedProvider {
141 name: Option<String>,
142 url: Option<String>,
143}
144
145#[derive(Debug, Serialize, Deserialize)]
146struct EmbedAuthor {
147 name: String,
148 url: Option<String>,
149 icon_url: Option<String>,
150 proxy_icon_url: Option<String>,
151}
152
153#[derive(Debug, Serialize, Deserialize)]
154
155struct EmbedField {
156 name: String,
157 value: String,
158 inline: Option<bool>,
159}
160
161#[derive(Debug, Serialize, Deserialize)]
162pub struct Reaction {
163 pub count: i32,
164 pub me: bool,
165 pub emoji: Emoji,
166}
167
168#[derive(Debug, Serialize, Deserialize)]
169pub enum Component {
170 ActionRow = 1,
171 Button = 2,
172 StringSelect = 3,
173 TextInput = 4,
174 UserSelect = 5,
175 RoleSelect = 6,
176 MentionableSelect = 7,
177 ChannelSelect = 8,
178}
179
180#[derive(Debug, Serialize, Deserialize)]
181pub struct MessageActivity {
182 #[serde(rename = "type")]
183 pub activity_type: i64,
184 pub party_id: Option<String>,
185}