From cb2ec9eb9aa9fcadc17061817c3d98f93a0674b1 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 22 Jun 2023 02:19:23 +0200 Subject: [PATCH] refactor: reformat using cargo --- src/api/client.rs | 24 +++++++++++++++--------- src/api/routing.rs | 4 +++- src/utils/message_response.rs | 3 ++- src/utils/moderation.rs | 9 ++++----- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/api/client.rs b/src/api/client.rs index 1f3fff2..e3be6a2 100644 --- a/src/api/client.rs +++ b/src/api/client.rs @@ -3,7 +3,6 @@ use reqwest::Client; use serde::de::DeserializeOwned; use super::model::auth::Authentication; - use super::routing::Endpoint; pub struct Api { @@ -32,7 +31,10 @@ impl Api { } } - async fn fire(&self, request_info: &RequestInfo<'_>) -> Result { + async fn fire( + &self, + request_info: &RequestInfo<'_>, + ) -> Result { let client = &self.client; let mut req = request_info.route.to_request(&self.server); @@ -40,7 +42,12 @@ impl Api { *req.headers_mut() = headers.clone(); } - client.execute(req).await?.error_for_status()?.json::().await + client + .execute(req) + .await? + .error_for_status()? + .json::() + .await } pub async fn authenticate( @@ -52,11 +59,10 @@ impl Api { secret: &self.client_secret, discord_id_hash, }; - self - .fire(&RequestInfo { - headers: None, - route, - }) - .await + self.fire(&RequestInfo { + headers: None, + route, + }) + .await } } diff --git a/src/api/routing.rs b/src/api/routing.rs index 27f1803..6b3034f 100644 --- a/src/api/routing.rs +++ b/src/api/routing.rs @@ -22,7 +22,9 @@ macro_rules! route { impl Endpoint<'_> { pub fn to_request(&self, server: &reqwest::Url) -> Request { match self { - Self::Authenticate { .. } => route!(self, server, "/auth/", POST), + Self::Authenticate { + .. + } => route!(self, server, "/auth/", POST), } } } diff --git a/src/utils/message_response.rs b/src/utils/message_response.rs index 1e88fae..9def3db 100644 --- a/src/utils/message_response.rs +++ b/src/utils/message_response.rs @@ -128,7 +128,8 @@ pub async fn handle_message_response(ctx: &serenity::Context, new_message: &sere if !channel_id .messages(&ctx.http, |b| b.limit(1).before(new_message)) .await - .unwrap().is_empty() + .unwrap() + .is_empty() { return; } diff --git a/src/utils/moderation.rs b/src/utils/moderation.rs index a8dd5b1..4bff8f2 100644 --- a/src/utils/moderation.rs +++ b/src/utils/moderation.rs @@ -18,10 +18,10 @@ use crate::{Context, Error}; pub enum ModerationKind { Mute(User, User, String, Option, Option), /* User, Command author, Reason, Expires, Error */ Unmute(User, User, Option), // User, Command author, Error - Ban(User, User, Option, Option), // User, Command author, Reason, Error - Unban(User, User, Option), // User, Command author, Error - Lock(GuildChannel, User, Option), // Channel name, Command author, Error - Unlock(GuildChannel, User, Option), // Channel name, Command author, Error + Ban(User, User, Option, Option), // User, Command author, Reason, Error + Unban(User, User, Option), // User, Command author, Error + Lock(GuildChannel, User, Option), // Channel name, Command author, Error + Unlock(GuildChannel, User, Option), // Channel name, Command author, Error } pub enum BanKind { Ban(User, Option, Option), // User, Amount of days to delete messages, Reason @@ -399,4 +399,3 @@ pub async fn mute_moderation( Ok((is_currently_muted, removed_roles)) } -