From c3cab53804e2f35c65c60ca66b1bfd404323b6ff Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 6 May 2023 22:23:34 +0200 Subject: [PATCH] impl SendMessageSchema --- src/api/schemas.rs | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/api/schemas.rs b/src/api/schemas.rs index 7672e55..215d7a6 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -244,11 +244,11 @@ pub struct TotpSchema { login_source: Option, } -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub struct MessageSendSchema { #[serde(rename = "type")] - message_type: i32, + message_type: Option, content: Option, nonce: Option, tts: Option, @@ -262,6 +262,37 @@ pub struct MessageSendSchema { attachments: Option>, } +// make a new() method for MessageSendSchema +impl MessageSendSchema { + pub fn new( + message_type: Option, + content: Option, + nonce: Option, + tts: Option, + embeds: Option>, + allowed_mentions: Option, + message_reference: Option, + components: Option>, + sticker_ids: Option>, + files: Option>>, + attachments: Option>, + ) -> MessageSendSchema { + MessageSendSchema { + message_type, + content, + nonce, + tts, + embeds, + allowed_mentions, + message_reference, + components, + sticker_ids, + files, + attachments, + } + } +} + // I know that some of these tests are... really really basic and unneccessary, but sometimes, I // just feel like writing tests, so there you go :) -@bitfl0wer #[cfg(test)]