From 1076c23403a43151f03ec7cd052cea3fdc48f6e4 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Fri, 5 May 2023 21:53:00 +0200 Subject: [PATCH] Add DiscordFileAttachment, change visibilities --- src/api/types.rs | 79 ++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/src/api/types.rs b/src/api/types.rs index 1059d62..3683bda 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -216,7 +216,7 @@ pub struct Message { mentions: Vec, mention_roles: Vec, mention_channels: Option>, - attachments: Vec, + pub attachments: Vec, embeds: Vec, reactions: Option>, nonce: Option, @@ -386,7 +386,7 @@ struct Attachment { /** Represents an Embed. [See the Discord Documentation](https://discord.com/developers/docs/resources/channel#embed-object). */ -struct Embed { +pub struct Embed { title: Option, #[serde(rename = "type")] embed_type: Option, @@ -539,9 +539,9 @@ struct InstallParams { } #[derive(Debug, Serialize, Deserialize)] -struct MessageReference { - message_id: Option, - channel_id: Option, +pub struct MessageReference { + message_id: String, + channel_id: String, guild_id: Option, fail_if_not_exists: Option, } @@ -655,7 +655,7 @@ struct DefaultReaction { } #[derive(Debug, Serialize, Deserialize)] -enum Component { +pub enum Component { ActionRow = 1, Button = 2, StringSelect = 3, @@ -842,32 +842,51 @@ pub struct GatewayPayload { impl WebSocketEvent for GatewayPayload {} +#[derive(Debug, Serialize, Deserialize)] pub struct DiscordFileAttachment { - pub name: i16, + pub id: i16, pub filename: String, - pub file: File, + description: Option, + content_type: Option, + size: i64, + url: String, + proxy_url: String, + height: Option, + width: Option, + ephemeral: Option, + duration_secs: Option, + waveform: Option, } -impl DiscordFileAttachment { - /** - Returns a [`Vec`], where [`DiscordFileAttachment`] represents a file - attachment according to Discord API spec (Unique name, filename and File). - # Arguments - * filename_file_map: A [`Vec`], where - * [`String`]: Filename of the file - * [`File`]: A [`File`] object. - */ - pub fn new(filename_file_vec: Vec<(String, File)>) -> Vec { - let mut return_vec: Vec = Vec::new(); - let mut counter = 0; - for (filename, file) in filename_file_vec { - return_vec.push(DiscordFileAttachment { - name: counter, - filename, - file, - }); - counter += 1; - } - return_vec - } +#[derive(Debug, Serialize, Deserialize)] + +pub struct PartialDiscordFileAttachment { + pub id: Option, + pub filename: Option, + description: Option, + content_type: Option, + size: Option, + url: Option, + proxy_url: Option, + height: Option, + width: Option, + ephemeral: Option, + duration_secs: Option, + waveform: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct AllowedMention { + parse: Vec, + roles: Vec, + users: Vec, + replied_user: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum AllowedMentionType { + Roles, + Users, + Everyone, }