Make MessageSendSchema fields public

This commit is contained in:
Vincent Junge 2023-06-19 14:21:27 +02:00
parent 208eeac536
commit f0241e0756
2 changed files with 18 additions and 61 deletions

View File

@ -8,42 +8,14 @@ use crate::types::entities::{
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub struct MessageSendSchema { pub struct MessageSendSchema {
#[serde(rename = "type")] #[serde(rename = "type")]
message_type: Option<i32>, pub message_type: Option<i32>,
content: Option<String>, pub content: Option<String>,
nonce: Option<String>, pub nonce: Option<String>,
tts: Option<bool>, pub tts: Option<bool>,
embeds: Option<Vec<Embed>>, pub embeds: Option<Vec<Embed>>,
allowed_mentions: Option<AllowedMention>, pub allowed_mentions: Option<AllowedMention>,
message_reference: Option<MessageReference>, pub message_reference: Option<MessageReference>,
components: Option<Vec<Component>>, pub components: Option<Vec<Component>>,
sticker_ids: Option<Vec<String>>, pub sticker_ids: Option<Vec<String>>,
pub attachments: Option<Vec<PartialDiscordFileAttachment>>, pub attachments: Option<Vec<PartialDiscordFileAttachment>>,
} }
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<AllowedMention>,
message_reference: Option<MessageReference>,
components: Option<Vec<Component>>,
sticker_ids: Option<Vec<String>>,
attachments: Option<Vec<PartialDiscordFileAttachment>>,
) -> MessageSendSchema {
MessageSendSchema {
message_type,
content,
nonce,
tts,
embeds,
allowed_mentions,
message_reference,
components,
sticker_ids,
attachments,
}
}
}

View File

@ -8,18 +8,10 @@ mod common;
#[tokio::test] #[tokio::test]
async fn send_message() { async fn send_message() {
let mut bundle = common::setup().await; let mut bundle = common::setup().await;
let mut message = types::MessageSendSchema::new( let mut message = types::MessageSendSchema {
None, content: Some("A Message!".to_string()),
Some("A Message!".to_string()), ..Default::default()
None, };
None,
None,
None,
None,
None,
None,
None,
);
let _ = bundle let _ = bundle
.user .user
.send_message(&mut message, bundle.channel.id.to_string(), None) .send_message(&mut message, bundle.channel.id.to_string(), None)
@ -53,18 +45,11 @@ async fn send_message_attachment() {
content: buffer, content: buffer,
}; };
let mut message = types::MessageSendSchema::new( let mut message = types::MessageSendSchema {
None, content: Some("trans rights now".to_string()),
Some("trans rights now".to_string()), attachments: Some(vec![attachment.clone()]),
None, ..Default::default()
None, };
None,
None,
None,
None,
None,
Some(vec![attachment.clone()]),
);
let vec_attach = vec![attachment.clone()]; let vec_attach = vec![attachment.clone()];
let _arg = Some(&vec_attach); let _arg = Some(&vec_attach);