mirror of
https://github.com/revanced/revanced-discord-bot.git
synced 2025-04-29 22:14:28 +02:00
refactor: reformat using cargo
This commit is contained in:
parent
8929489896
commit
cb2ec9eb9a
@ -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<T: DeserializeOwned>(&self, request_info: &RequestInfo<'_>) -> Result<T, reqwest::Error> {
|
||||
async fn fire<T: DeserializeOwned>(
|
||||
&self,
|
||||
request_info: &RequestInfo<'_>,
|
||||
) -> Result<T, reqwest::Error> {
|
||||
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::<T>().await
|
||||
client
|
||||
.execute(req)
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.json::<T>()
|
||||
.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
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ use crate::{Context, Error};
|
||||
pub enum ModerationKind {
|
||||
Mute(User, User, String, Option<String>, Option<Error>), /* User, Command author, Reason, Expires, Error */
|
||||
Unmute(User, User, Option<Error>), // User, Command author, Error
|
||||
Ban(User, User, Option<String>, Option<SerenityError>), // User, Command author, Reason, Error
|
||||
Unban(User, User, Option<SerenityError>), // User, Command author, Error
|
||||
Lock(GuildChannel, User, Option<Error>), // Channel name, Command author, Error
|
||||
Unlock(GuildChannel, User, Option<Error>), // Channel name, Command author, Error
|
||||
Ban(User, User, Option<String>, Option<SerenityError>), // User, Command author, Reason, Error
|
||||
Unban(User, User, Option<SerenityError>), // User, Command author, Error
|
||||
Lock(GuildChannel, User, Option<Error>), // Channel name, Command author, Error
|
||||
Unlock(GuildChannel, User, Option<Error>), // Channel name, Command author, Error
|
||||
}
|
||||
pub enum BanKind {
|
||||
Ban(User, Option<u8>, Option<String>), // User, Amount of days to delete messages, Reason
|
||||
@ -399,4 +399,3 @@ pub async fn mute_moderation(
|
||||
|
||||
Ok((is_currently_muted, removed_roles))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user