impl SendMessageSchema

This commit is contained in:
bitfl0wer 2023-05-06 22:23:34 +02:00
parent b1b684e3b5
commit c3cab53804
No known key found for this signature in database
GPG Key ID: 84BBB60DF895ABF2
1 changed files with 33 additions and 2 deletions

View File

@ -244,11 +244,11 @@ pub struct TotpSchema {
login_source: Option<String>, login_source: Option<String>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub struct MessageSendSchema { pub struct MessageSendSchema {
#[serde(rename = "type")] #[serde(rename = "type")]
message_type: i32, message_type: Option<i32>,
content: Option<String>, content: Option<String>,
nonce: Option<String>, nonce: Option<String>,
tts: Option<bool>, tts: Option<bool>,
@ -262,6 +262,37 @@ pub struct MessageSendSchema {
attachments: Option<Vec<super::PartialDiscordFileAttachment>>, attachments: Option<Vec<super::PartialDiscordFileAttachment>>,
} }
// make a new() method for MessageSendSchema
impl MessageSendSchema {
pub fn new(
message_type: Option<i32>,
content: Option<String>,
nonce: Option<String>,
tts: Option<bool>,
embeds: Option<Vec<Embed>>,
allowed_mentions: Option<super::AllowedMention>,
message_reference: Option<super::MessageReference>,
components: Option<Vec<super::Component>>,
sticker_ids: Option<Vec<String>>,
files: Option<HashMap<String, Vec<u8>>>,
attachments: Option<Vec<super::PartialDiscordFileAttachment>>,
) -> 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 // 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 // just feel like writing tests, so there you go :) -@bitfl0wer
#[cfg(test)] #[cfg(test)]