From ca8f94c18e1b6b2c5be93410e78332b347833bdc Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 21:42:43 +0200 Subject: [PATCH 01/17] create src/api/guilds/guilds.rs --- src/api/guilds/guilds.rs | 0 src/api/guilds/mod.rs | 3 +++ src/api/mod.rs | 2 ++ 3 files changed, 5 insertions(+) create mode 100644 src/api/guilds/guilds.rs create mode 100644 src/api/guilds/mod.rs diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/api/guilds/mod.rs b/src/api/guilds/mod.rs new file mode 100644 index 0000000..242a03e --- /dev/null +++ b/src/api/guilds/mod.rs @@ -0,0 +1,3 @@ +pub mod guilds; + +use guilds::*; diff --git a/src/api/mod.rs b/src/api/mod.rs index eb12765..37abc50 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,11 +1,13 @@ pub mod auth; pub mod channels; +pub mod guilds; pub mod policies; pub mod schemas; pub mod types; pub mod users; pub use channels::messages::*; +pub use guilds::*; pub use policies::instance::instance::*; pub use policies::instance::limits::*; pub use schemas::*; From c436fdb8573e0369775e1e5fc9d9b95e67644e85 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 22:06:44 +0200 Subject: [PATCH 02/17] Remove panic on send_request error --- src/limit.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/limit.rs b/src/limit.rs index 82f5732..9de72af 100644 --- a/src/limit.rs +++ b/src/limit.rs @@ -78,7 +78,11 @@ impl LimitedRequester { let result = self.http.execute(built_request).await; let response = match result { Ok(is_response) => is_response, - Err(e) => panic!("An error occured while processing the response: {}", e), + Err(e) => { + return Err(InstanceServerError::ReceivedErrorCodeError { + error_code: e.to_string(), + }) + } }; self.update_limits( &response, @@ -86,7 +90,13 @@ impl LimitedRequester { instance_rate_limits, user_rate_limits, ); - Ok(response) + if !response.status().is_success() { + Err(InstanceServerError::ReceivedErrorCodeError { + error_code: response.status().as_str().to_string(), + }) + } else { + Ok(response) + } } else { self.requests.push_back(TypedRequest { request, From 5031db6547e0411d50feb1a4c2720b2fd92e2607 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 22:10:46 +0200 Subject: [PATCH 03/17] Update docs, remove panic in favor of Err Result --- src/limit.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/limit.rs b/src/limit.rs index 9de72af..07dec0f 100644 --- a/src/limit.rs +++ b/src/limit.rs @@ -57,7 +57,8 @@ impl LimitedRequester { ## Errors - This method will panic, if: + This method will error, if: + - The request does not return a success status code (200-299) - The supplied [`RequestBuilder`](reqwest::RequestBuilder) contains invalid or incomplete information - There has been an error with processing (unwrapping) the [`Response`](`reqwest::Response`) @@ -72,9 +73,15 @@ impl LimitedRequester { user_rate_limits: &mut Limits, ) -> Result { if self.can_send_request(limit_type, instance_rate_limits, user_rate_limits) { - let built_request = request - .build() - .unwrap_or_else(|e| panic!("Error while building the Request for sending: {}", e)); + let built_request = match request.build() { + Ok(request) => request, + Err(e) => { + return Err(InstanceServerError::RequestErrorError { + url: "".to_string(), + error: e.to_string(), + }) + } + }; let result = self.http.execute(built_request).await; let response = match result { Ok(is_response) => is_response, From e0a45edb3c9eb70aabddf80eca7fc68d00f2e5cf Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 22:11:06 +0200 Subject: [PATCH 04/17] Add GuildCreateSchema as per Spacebar Docs --- src/api/schemas.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/schemas.rs b/src/api/schemas.rs index 670a828..6c021b6 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::errors::FieldFormatError; -use super::Embed; +use super::{Channel, Embed}; /** A struct that represents a well-formed email address. @@ -287,6 +287,18 @@ impl MessageSendSchema { } } +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] +pub struct GuildCreateSchema { + name: Option, + region: Option, + icon: Option, + channels: Option>, + guild_template_code: Option, + system_channel_id: Option, + rules_channel_id: Option, +} + // 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)] From 1934622e4c9454c7492dda419f904b48a82d3a08 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 22:14:53 +0200 Subject: [PATCH 05/17] Implement Guild::create() --- src/api/guilds/guilds.rs | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index e69de29..d3fd17a 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -0,0 +1,42 @@ +use serde_json::to_string; + +use crate::api::schemas; +use crate::api::types; + +impl<'a> types::Guild { + pub async fn create( + user: &mut types::User<'a>, + instance: &mut crate::instance::Instance, + guild_create_schema: &schemas::GuildCreateSchema, + ) -> Result { + let url = format!("{}/guilds/", instance.urls.get_api().to_string()); + let limits_user = user.limits.get_as_mut(); + let limits_instance = instance.limits.get_as_mut(); + let request = reqwest::Client::new() + .post(url.clone()) + .bearer_auth(user.token.clone()) + .body(to_string(guild_create_schema).unwrap()); + let mut requester = crate::limit::LimitedRequester::new().await; + let result = match requester + .send_request( + request, + crate::api::limits::LimitType::Guild, + limits_instance, + limits_user, + ) + .await + { + Ok(result) => result, + Err(e) => return Err(e), + }; + return Ok(match result.text().await { + Ok(string) => string, + Err(e) => { + return Err(crate::errors::InstanceServerError::RequestErrorError { + url: url.to_string(), + error: e.to_string(), + }) + } + }); + } +} From ea454228ac0d4e1e4c6352ed165b6ed9ce32660c Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 22:55:17 +0200 Subject: [PATCH 06/17] Add documentation --- src/api/guilds/guilds.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index d3fd17a..b067b05 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -4,6 +4,34 @@ use crate::api::schemas; use crate::api::types; impl<'a> types::Guild { + /// Creates a new guild with the given parameters. + /// + /// # Arguments + /// + /// * `user` - A mutable reference to the user creating the guild. + /// * `instance` - A mutable reference to the instance where the guild will be created. + /// * `guild_create_schema` - A reference to the schema containing the guild creation parameters. + /// + /// # Returns + /// + /// A `Result` containing the ID of the newly created guild, or an error if the request fails. + /// + /// # Errors + /// + /// Returns an `InstanceServerError` if the request fails. + /// + /// # Examples + /// + /// ```rust + /// let guild_create_schema = chorus::api::schemas::GuildCreateSchema::new(insert args here); + /// + /// let result = Guild::create(&mut user, &mut instance, &guild_create_schema).await; + /// + /// match result { + /// Ok(guild_id) => println!("Created guild with ID {}", guild_id), + /// Err(e) => println!("Failed to create guild: {}", e), + /// } + /// ``` pub async fn create( user: &mut types::User<'a>, instance: &mut crate::instance::Instance, From 3fca30db350b8b58d1d71b4bbbd9598b01dd65d6 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 23:15:28 +0200 Subject: [PATCH 07/17] start implementing get() --- src/api/guilds/guilds.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index b067b05..f56acd0 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -35,7 +35,7 @@ impl<'a> types::Guild { pub async fn create( user: &mut types::User<'a>, instance: &mut crate::instance::Instance, - guild_create_schema: &schemas::GuildCreateSchema, + guild_create_schema: schemas::GuildCreateSchema, ) -> Result { let url = format!("{}/guilds/", instance.urls.get_api().to_string()); let limits_user = user.limits.get_as_mut(); @@ -43,7 +43,7 @@ impl<'a> types::Guild { let request = reqwest::Client::new() .post(url.clone()) .bearer_auth(user.token.clone()) - .body(to_string(guild_create_schema).unwrap()); + .body(to_string(&guild_create_schema).unwrap()); let mut requester = crate::limit::LimitedRequester::new().await; let result = match requester .send_request( @@ -67,4 +67,16 @@ impl<'a> types::Guild { } }); } + pub async fn get( + user: &mut types::User<'a>, + instance: &mut crate::instance::Instance, + id: String, + ) { + let url = format!("{}/guilds/{}/", instance.urls.get_api().to_string(), id); + let limits_user = user.limits.get_as_mut(); + let limits_instance = instance.limits.get_as_mut(); + let request = reqwest::Client::new() + .get(url.clone()) + .bearer_auth(user.token.clone()); + } } From 51ecf888b8b38ef255796313df907d8a9bb2c5c9 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 May 2023 23:45:49 +0200 Subject: [PATCH 08/17] remove get() --- src/api/guilds/guilds.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index f56acd0..7e1bb94 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -67,16 +67,4 @@ impl<'a> types::Guild { } }); } - pub async fn get( - user: &mut types::User<'a>, - instance: &mut crate::instance::Instance, - id: String, - ) { - let url = format!("{}/guilds/{}/", instance.urls.get_api().to_string(), id); - let limits_user = user.limits.get_as_mut(); - let limits_instance = instance.limits.get_as_mut(); - let request = reqwest::Client::new() - .get(url.clone()) - .bearer_auth(user.token.clone()); - } } From 598ad093a160f40607b6772fa49663d8de30d5eb Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 13:07:46 +0200 Subject: [PATCH 09/17] Improve error handling on request sending --- src/errors.rs | 2 ++ src/limit.rs | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 76d16bd..e50a931 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -19,6 +19,8 @@ custom_error! { InvalidFormBodyError{error_type: String, error:String} = "The server responded with: {error_type}: {error}", RateLimited = "Ratelimited.", MultipartCreationError{error: String} = "Got an error whilst creating the form: {}", + TokenExpired = "Token expired, invalid or not found.", + NoPermission = "You do not have the permissions needed to perform this action.", } custom_error! { diff --git a/src/limit.rs b/src/limit.rs index 07dec0f..7212e7c 100644 --- a/src/limit.rs +++ b/src/limit.rs @@ -98,9 +98,15 @@ impl LimitedRequester { user_rate_limits, ); if !response.status().is_success() { - Err(InstanceServerError::ReceivedErrorCodeError { - error_code: response.status().as_str().to_string(), - }) + match response.status().as_u16() { + 401 => return Err(InstanceServerError::TokenExpired), + 403 => return Err(InstanceServerError::TokenExpired), + _ => { + return Err(InstanceServerError::ReceivedErrorCodeError { + error_code: response.status().as_str().to_string(), + }) + } + } } else { Ok(response) } From 4b4adbe1cc205c28785c18f98e4612429f45a2bb Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 13:11:50 +0200 Subject: [PATCH 10/17] impl ToString for LimitType --- src/api/policies/instance/limits.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/api/policies/instance/limits.rs b/src/api/policies/instance/limits.rs index 2818135..1c96883 100644 --- a/src/api/policies/instance/limits.rs +++ b/src/api/policies/instance/limits.rs @@ -1,5 +1,5 @@ pub mod limits { - use std::{collections::HashMap}; + use std::collections::HashMap; use reqwest::Client; use serde::{Deserialize, Serialize}; @@ -20,6 +20,23 @@ pub mod limits { Webhook, } + impl ToString for LimitType { + fn to_string(&self) -> String { + match self { + LimitType::AuthRegister => "AuthRegister".to_string(), + LimitType::AuthLogin => "AuthLogin".to_string(), + LimitType::AbsoluteMessage => "AbsoluteMessage".to_string(), + LimitType::AbsoluteRegister => "AbsoluteRegister".to_string(), + LimitType::Global => "Global".to_string(), + LimitType::Ip => "Ip".to_string(), + LimitType::Channel => "Channel".to_string(), + LimitType::Error => "Error".to_string(), + LimitType::Guild => "Guild".to_string(), + LimitType::Webhook => "Webhook".to_string(), + } + } + } + #[derive(Debug, Deserialize, Serialize)] #[allow(non_snake_case)] pub struct User { From d797a1000966e2496bd5aa630f18fe76fc260374 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 13:12:02 +0200 Subject: [PATCH 11/17] Add RateLimit information --- src/errors.rs | 2 +- src/limit.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index e50a931..599b262 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -17,7 +17,7 @@ custom_error! { ReceivedErrorCodeError{error_code:String} = "Received the following error code while requesting from the route: {error_code}", CantGetInfoError{error:String} = "Something seems to be wrong with the instance. Cannot get information about the instance: {error}", InvalidFormBodyError{error_type: String, error:String} = "The server responded with: {error_type}: {error}", - RateLimited = "Ratelimited.", + RateLimited{bucket:String} = "Ratelimited on Bucket {bucket}", MultipartCreationError{error: String} = "Got an error whilst creating the form: {}", TokenExpired = "Token expired, invalid or not found.", NoPermission = "You do not have the permissions needed to perform this action.", diff --git a/src/limit.rs b/src/limit.rs index 7212e7c..cc058b6 100644 --- a/src/limit.rs +++ b/src/limit.rs @@ -115,7 +115,9 @@ impl LimitedRequester { request, limit_type, }); - Err(InstanceServerError::RateLimited) + Err(InstanceServerError::RateLimited { + bucket: limit_type.to_string(), + }) } } From 833c3733d7db7a91646a296caab53dbe0d170901 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 14:16:21 +0200 Subject: [PATCH 12/17] Add guild delete route --- src/api/guilds/guilds.rs | 56 ++++++++++++++++++++++++++++++++++++++++ src/errors.rs | 1 + 2 files changed, 57 insertions(+) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index 7e1bb94..bd08075 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -2,6 +2,7 @@ use serde_json::to_string; use crate::api::schemas; use crate::api::types; +use crate::errors::InstanceServerError; impl<'a> types::Guild { /// Creates a new guild with the given parameters. @@ -67,4 +68,59 @@ impl<'a> types::Guild { } }); } + + /// Deletes a guild. + /// + /// # Arguments + /// + /// * `user` - A mutable reference to a `User` instance. + /// * `instance` - A mutable reference to an `Instance` instance. + /// * `guild_id` - A `String` representing the ID of the guild to delete. + /// + /// # Returns + /// + /// An `Option` containing an `InstanceServerError` if an error occurred during the request, otherwise `None`. + /// + /// # Example + /// + /// ```rust + /// let mut user = User::new(); + /// let mut instance = Instance::new(); + /// let guild_id = String::from("1234567890"); + /// + /// match Guild::delete(&mut user, &mut instance, guild_id) { + /// Some(e) => println!("Error deleting guild: {:?}", e), + /// None => println!("Guild deleted successfully"), + /// } + /// ``` + pub async fn delete( + user: &mut types::User<'a>, + instance: &mut crate::instance::Instance, + guild_id: String, + ) -> Option { + let url = format!( + "{}/guilds/{}/delete/", + instance.urls.get_api().to_string(), + guild_id + ); + let limits_user = user.limits.get_as_mut(); + let limits_instance = instance.limits.get_as_mut(); + let request = reqwest::Client::new() + .post(url.clone()) + .bearer_auth(user.token.clone()); + let mut requester = crate::limit::LimitedRequester::new().await; + let result = requester + .send_request( + request, + crate::api::limits::LimitType::Guild, + limits_instance, + limits_user, + ) + .await; + if result.is_err() { + Some(result.err().unwrap()) + } else { + None + } + } } diff --git a/src/errors.rs b/src/errors.rs index 599b262..d449559 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -21,6 +21,7 @@ custom_error! { MultipartCreationError{error: String} = "Got an error whilst creating the form: {}", TokenExpired = "Token expired, invalid or not found.", NoPermission = "You do not have the permissions needed to perform this action.", + NotFound{error: String} = "The provided resource hasn't been found: {}", } custom_error! { From 120cdfd14fbc9964dda5074c4091aa4a44627a4d Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 22:45:18 +0200 Subject: [PATCH 13/17] Change function signatures, add tests --- src/api/guilds/guilds.rs | 81 ++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 19 deletions(-) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index bd08075..9bc6c78 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -1,3 +1,4 @@ +use serde_json::from_str; use serde_json::to_string; use crate::api::schemas; @@ -35,12 +36,12 @@ impl<'a> types::Guild { /// ``` pub async fn create( user: &mut types::User<'a>, - instance: &mut crate::instance::Instance, + url_api: &str, guild_create_schema: schemas::GuildCreateSchema, ) -> Result { - let url = format!("{}/guilds/", instance.urls.get_api().to_string()); + let url = format!("{}/guilds/", url_api); let limits_user = user.limits.get_as_mut(); - let limits_instance = instance.limits.get_as_mut(); + let limits_instance = &mut user.belongs_to.limits; let request = reqwest::Client::new() .post(url.clone()) .bearer_auth(user.token.clone()) @@ -58,15 +59,8 @@ impl<'a> types::Guild { Ok(result) => result, Err(e) => return Err(e), }; - return Ok(match result.text().await { - Ok(string) => string, - Err(e) => { - return Err(crate::errors::InstanceServerError::RequestErrorError { - url: url.to_string(), - error: e.to_string(), - }) - } - }); + let id: types::GuildCreateResponse = from_str(&result.text().await.unwrap()).unwrap(); + Ok(id.id) } /// Deletes a guild. @@ -95,16 +89,12 @@ impl<'a> types::Guild { /// ``` pub async fn delete( user: &mut types::User<'a>, - instance: &mut crate::instance::Instance, + url_api: &str, guild_id: String, ) -> Option { - let url = format!( - "{}/guilds/{}/delete/", - instance.urls.get_api().to_string(), - guild_id - ); + let url = format!("{}/guilds/{}/delete/", url_api, guild_id); let limits_user = user.limits.get_as_mut(); - let limits_instance = instance.limits.get_as_mut(); + let limits_instance = &mut user.belongs_to.limits; let request = reqwest::Client::new() .post(url.clone()) .bearer_auth(user.token.clone()); @@ -124,3 +114,56 @@ impl<'a> types::Guild { } } } + +#[cfg(test)] +mod test { + use crate::api::schemas; + use crate::api::types; + use crate::instance::Instance; + + #[tokio::test] + async fn guild_creation_deletion() { + let mut instance = Instance::new( + crate::URLBundle { + api: "http://localhost:3001/api".to_string(), + wss: "ws://localhost:3001/".to_string(), + cdn: "http://localhost:3001".to_string(), + }, + crate::limit::LimitedRequester::new().await, + ) + .await + .unwrap(); + let login_schema: schemas::LoginSchema = schemas::LoginSchema::new( + schemas::AuthUsername::new("user@test.xyz".to_string()).unwrap(), + "transrights".to_string(), + None, + None, + None, + None, + ) + .unwrap(); + let mut user = instance.login_account(&login_schema).await.unwrap(); + + let guild_create_schema = schemas::GuildCreateSchema { + name: Some("test".to_string()), + region: None, + icon: None, + channels: None, + guild_template_code: None, + system_channel_id: None, + rules_channel_id: None, + }; + + let guild = + types::Guild::create(&mut user, "http://localhost:3001/api", guild_create_schema) + .await + .unwrap(); + + println!("{}", guild); + + match types::Guild::delete(&mut user, "http://localhost:3001/api", guild).await { + None => assert!(true), + Some(_) => assert!(false), + } + } +} From fbfd0e627f84493a950795a96828c85d5232db3f Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 22:45:31 +0200 Subject: [PATCH 14/17] Remove unused import --- src/api/channels/messages.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/channels/messages.rs b/src/api/channels/messages.rs index d05f640..ffa3f06 100644 --- a/src/api/channels/messages.rs +++ b/src/api/channels/messages.rs @@ -5,7 +5,6 @@ pub mod messages { use serde_json::to_string; use crate::api::types::{Message, PartialDiscordFileAttachment, User}; - use crate::errors::InstanceServerError; use crate::limit::LimitedRequester; impl Message { From b4cc8fd64b0dbadd7d6f4249e4eef5417bbc0bc6 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 22:45:42 +0200 Subject: [PATCH 15/17] add type guildcreateresponse --- src/api/types.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/types.rs b/src/api/types.rs index c87786b..bfb6861 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -1477,3 +1477,8 @@ pub struct Webhook { pub source_guild: Option, pub id: String, } + +#[derive(Serialize, Deserialize, Debug, Default, Clone)] +pub struct GuildCreateResponse { + pub id: String, +} From e552bdb352480cf4236a27e22560bad29324fcf1 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 22:45:55 +0200 Subject: [PATCH 16/17] make fields on GuildCreateSchema pub --- src/api/schemas.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/schemas.rs b/src/api/schemas.rs index 6c021b6..1fd0e76 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -290,13 +290,13 @@ impl MessageSendSchema { #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub struct GuildCreateSchema { - name: Option, - region: Option, - icon: Option, - channels: Option>, - guild_template_code: Option, - system_channel_id: Option, - rules_channel_id: Option, + pub name: Option, + pub region: Option, + pub icon: Option, + pub channels: Option>, + pub guild_template_code: Option, + pub system_channel_id: Option, + pub rules_channel_id: Option, } // I know that some of these tests are... really really basic and unneccessary, but sometimes, I From aaa16ef532534941c646ce61e039f3e3bbc70e92 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 14 May 2023 22:47:34 +0200 Subject: [PATCH 17/17] remove accidental doctests --- src/api/guilds/guilds.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index 9bc6c78..23249b9 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -24,7 +24,7 @@ impl<'a> types::Guild { /// /// # Examples /// - /// ```rust + /// ```rs /// let guild_create_schema = chorus::api::schemas::GuildCreateSchema::new(insert args here); /// /// let result = Guild::create(&mut user, &mut instance, &guild_create_schema).await; @@ -77,7 +77,7 @@ impl<'a> types::Guild { /// /// # Example /// - /// ```rust + /// ```rs /// let mut user = User::new(); /// let mut instance = Instance::new(); /// let guild_id = String::from("1234567890");