Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AsianIntel committed Nov 4, 2024
1 parent 925af58 commit 0e10898
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 52 deletions.
5 changes: 1 addition & 4 deletions rowifi/src/commands/custombinds/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ pub async fn delete_custombind_func(
.footer(EmbedFooterBuilder::new("RoWifi").build())
.timestamp(Timestamp::from_secs(Utc::now().timestamp()).unwrap())
.title("Deletion Failed")
.description(format!(
"Custombind with ID {} does not exist",
args.id
))
.description(format!("Custombind with ID {} does not exist", args.id))
.build();
ctx.respond(&bot).embeds(&[embed]).unwrap().await?;
} else {
Expand Down
19 changes: 13 additions & 6 deletions rowifi/src/commands/denylists/custom.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rowifi_core::denylists::add::{add_denylist, AddDenylistError, DenylistArguments};
use rowifi_framework::prelude::*;
use rowifi_models::{
deny_list::{DenyListActionType, DenyListType},
Expand All @@ -6,7 +7,6 @@ use rowifi_models::{
util::Timestamp,
},
};
use rowifi_core::denylists::add::{add_denylist, AddDenylistError, DenylistArguments};

#[derive(Arguments, Debug)]
pub struct DenylistRouteArguments {
Expand Down Expand Up @@ -57,16 +57,20 @@ pub async fn add_custom_denylist_func(
reason,
user_id: None,
group_id: None,
code: Some(args.code.clone())
code: Some(args.code.clone()),
},
)
.await
{
Ok(res) => res,
Err(AddDenylistError::MissingUser | AddDenylistError::MissingGroup | AddDenylistError::MissingCode) => {
Err(
AddDenylistError::MissingUser
| AddDenylistError::MissingGroup
| AddDenylistError::MissingCode,
) => {
// Ignore this case since it doesn't occur in slash commands
return Ok(());
},
}
Err(AddDenylistError::IncorrectCode(err)) => {
ctx.respond(&bot).content(&err).unwrap().await?;
return Ok(());
Expand All @@ -75,7 +79,10 @@ pub async fn add_custom_denylist_func(
};

let name = format!("Type: {}", denylist.kind());
let desc = format!("Code: `{}`\nAction: {}\nReason: {}", args.code, denylist.action_type, denylist.reason);
let desc = format!(
"Code: `{}`\nAction: {}\nReason: {}",
args.code, denylist.action_type, denylist.reason
);

let embed = EmbedBuilder::new()
.color(DARK_GREEN)
Expand Down Expand Up @@ -103,4 +110,4 @@ pub async fn add_custom_denylist_func(
}

Ok(())
}
}
12 changes: 10 additions & 2 deletions rowifi/src/commands/denylists/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,23 @@ Oh no! A group with the ID {} does not exist. Ensure you have entered the ID cor
.await
{
Ok(res) => res,
Err(AddDenylistError::MissingUser | AddDenylistError::MissingGroup | AddDenylistError::MissingCode | AddDenylistError::IncorrectCode(_)) => {
Err(
AddDenylistError::MissingUser
| AddDenylistError::MissingGroup
| AddDenylistError::MissingCode
| AddDenylistError::IncorrectCode(_),
) => {
// Ignore this case since this won't occur in slash commands
return Ok(());
}
Err(AddDenylistError::Generic(err)) => return Err(err),
};

let name = format!("Type: {}", denylist.kind());
let desc = format!("Group Id: {}\nAction: {}\nReason: {}", args.group_id, denylist.action_type, denylist.reason);
let desc = format!(
"Group Id: {}\nAction: {}\nReason: {}",
args.group_id, denylist.action_type, denylist.reason
);

let embed = EmbedBuilder::new()
.color(DARK_GREEN)
Expand Down
11 changes: 8 additions & 3 deletions rowifi/src/commands/denylists/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod custom;
mod delete;
mod group;
mod user;
mod custom;

use itertools::Itertools;
use rowifi_framework::{prelude::*, utils::paginate_embeds};
Expand All @@ -15,10 +15,10 @@ use rowifi_models::{
use std::sync::Arc;
use twilight_standby::Standby;

pub use custom::add_custom_denylist;
pub use delete::delete_denylist;
pub use group::add_group_denylist;
pub use user::add_user_denylist;
pub use custom::add_custom_denylist;

pub async fn view_denylists(
bot: Extension<BotContext>,
Expand Down Expand Up @@ -70,7 +70,12 @@ This server has no denylists configured. Looking to add one? Use the command `/d
.description(format!("Page {}", page_count + 1));
for denylist in denylist_chunk {
let name = format!("ID: {}", denylist.id);
let mut desc = format!("Type: `{}`\nAction: {}\nReason: {}\n", denylist.kind(), denylist.action_type, denylist.reason);
let mut desc = format!(
"Type: `{}`\nAction: {}\nReason: {}\n",
denylist.kind(),
denylist.action_type,
denylist.reason
);
match denylist.data {
DenyListData::User(user_id) => desc.push_str(&format!("User ID: {user_id}")),
DenyListData::Group(group_id) => desc.push_str(&format!("Group ID: {group_id}")),
Expand Down
12 changes: 10 additions & 2 deletions rowifi/src/commands/denylists/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,23 @@ Oh no! A user with the name `{}` does not exist.
.await
{
Ok(res) => res,
Err(AddDenylistError::MissingUser | AddDenylistError::MissingGroup | AddDenylistError::MissingCode | AddDenylistError::IncorrectCode(_)) => {
Err(
AddDenylistError::MissingUser
| AddDenylistError::MissingGroup
| AddDenylistError::MissingCode
| AddDenylistError::IncorrectCode(_),
) => {
// Ignore this case since it doesn't occur in slash commands
return Ok(());
}
Err(AddDenylistError::Generic(err)) => return Err(err),
};

let name = format!("Type: {}", denylist.kind());
let desc = format!("User Id: {}\nAction: {}\nReason: {}", user.id, denylist.action_type, denylist.reason);
let desc = format!(
"User Id: {}\nAction: {}\nReason: {}",
user.id, denylist.action_type, denylist.reason
);

let embed = EmbedBuilder::new()
.color(DARK_GREEN)
Expand Down
4 changes: 3 additions & 1 deletion rowifi/src/commands/events/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ pub async fn view_attendee_events(
command: Command<EventViewArguments>,
) -> impl IntoResponse {
tokio::spawn(async move {
if let Err(err) = view_attendee_events_func(&bot, standby.0, &command.ctx, command.args).await {
if let Err(err) =
view_attendee_events_func(&bot, standby.0, &command.ctx, command.args).await
{
handle_error(bot.0, command.ctx, err).await;
}
});
Expand Down
4 changes: 1 addition & 3 deletions rowifi/src/commands/rankbinds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ This server has no rankbinds configured. Looking to add one? Use the command `/r
let mut embed = EmbedBuilder::new()
.color(DARK_GREEN)
.footer(EmbedFooterBuilder::new("RoWifi").build())
.timestamp(
Timestamp::from_secs(Utc::now().timestamp()).unwrap(),
)
.timestamp(Timestamp::from_secs(Utc::now().timestamp()).unwrap())
.title("Rankbinds")
.description(format!("Group {} | Page {}", group.0, page_count + 1));
let rbs = rbs.sorted_unstable_by_key(|r| r.group_rank_id);
Expand Down
23 changes: 13 additions & 10 deletions rowifi/src/commands/rankbinds/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,19 @@ async fn new_rankbind_func(
.timestamp(Timestamp::from_secs(Utc::now().timestamp()).unwrap())
.title(format!("Action by <@{}>", ctx.author_id))
.description("Rankbind added")
.field(EmbedFieldBuilder::new(format!("**Rank Id: {}**\n", res.bind.group_rank_id), format!(
"Template: {}\nPriority: {}\n Roles: {}",
res.bind.template,
res.bind.priority,
res.bind
.discord_roles
.iter()
.map(|r| r.0.mention().to_string())
.collect::<String>()
)))
.field(EmbedFieldBuilder::new(
format!("**Rank Id: {}**\n", res.bind.group_rank_id),
format!(
"Template: {}\nPriority: {}\n Roles: {}",
res.bind.template,
res.bind.priority,
res.bind
.discord_roles
.iter()
.map(|r| r.0.mention().to_string())
.collect::<String>()
),
))
.build();
let _ = bot
.http
Expand Down
2 changes: 1 addition & 1 deletion rowifi/src/commands/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mod mass_update;
mod serverinfo;

pub use mass_update::{update_all, update_role};
pub use serverinfo::serverinfo;
pub use serverinfo::serverinfo;
2 changes: 1 addition & 1 deletion rowifi/src/commands/user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod info;
mod update;
mod verify;

pub use self::update::{update_route, debug_update};
pub use self::update::{debug_update, update_route};
pub use accounts::{account_default, account_delete, account_switch, account_view};
pub use info::userinfo;
pub use verify::verify_route;
5 changes: 4 additions & 1 deletion rowifi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {

#[cfg(feature = "tower")]
{
use rowifi_tower::{commands::{set_rank, xp_add, xp_remove, xp_set}, init_tower};
use rowifi_tower::{
commands::{set_rank, xp_add, xp_remove, xp_set},
init_tower,
};
router = router
.route("/setrank", post(set_rank))
.route("/xp/add", post(xp_add))
Expand Down
2 changes: 1 addition & 1 deletion rowifi_core/src/assetbinds/add.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::error::RoError;
use chrono::Utc;
use rowifi_database::{postgres::types::Json, Database};
use rowifi_models::{
Expand All @@ -9,7 +10,6 @@ use rowifi_models::{
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::error::RoError;

#[derive(Debug, Serialize)]
pub struct AddAssetbind {
Expand Down
4 changes: 2 additions & 2 deletions rowifi_core/src/denylists/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ pub async fn add_denylist(
} else {
return Err(AddDenylistError::MissingUser);
}
},
}
DenyListType::Group => {
if let Some(group_id) = args.group_id {
DenyListData::Group(group_id)
} else {
return Err(AddDenylistError::MissingGroup);
}
},
}
DenyListType::Custom => {
if let Some(code) = args.code {
if let Err(err) = parser(&code) {
Expand Down
2 changes: 1 addition & 1 deletion rowifi_core/src/rankbinds/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub async fn add_rankbind(
kind: AuditLogKind::BindCreate,
guild_id: Some(guild_id),
user_id: Some(author_id),
timestamp:Utc::now(),
timestamp: Utc::now(),
metadata: AuditLogData::BindCreate {
count: 1,
kind: BindType::Rank,
Expand Down
5 changes: 4 additions & 1 deletion rowifi_core/src/user/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ impl UpdateUser<'_> {
.sorted_by_key(|d| d.action_type)
.last();
if let Some(deny_list) = active_deny_list {
return Err(UpdateUserError::DenyList((self.member.id, (*deny_list).clone())));
return Err(UpdateUserError::DenyList((
self.member.id,
(*deny_list).clone(),
)));
}

let mut nickname_bind: Option<Bind> = None;
Expand Down
9 changes: 5 additions & 4 deletions rowifi_framework/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use rowifi_models::{
application::interaction::application_command::{CommandDataOption, CommandOptionValue},
id::{marker::RoleMarker, Id},
},
id::{RoleId, UserId}, roblox::id::GroupId,
id::{RoleId, UserId},
roblox::id::GroupId,
};
use std::{
error::Error as StdError,
Expand Down Expand Up @@ -167,7 +168,7 @@ impl Argument for RoleId {
fn from_interaction(option: &CommandDataOption) -> Result<Self, ArgumentError> {
match option.value {
CommandOptionValue::Role(role) => Ok(RoleId(role)),
_ => unreachable!()
_ => unreachable!(),
}
}
}
Expand All @@ -176,7 +177,7 @@ impl Argument for GroupId {
fn from_interaction(option: &CommandDataOption) -> Result<Self, ArgumentError> {
match option.value {
CommandOptionValue::Integer(group) => Ok(GroupId(group as u64)),
_ => unreachable!()
_ => unreachable!(),
}
}
}
Expand All @@ -185,7 +186,7 @@ impl Argument for bool {
fn from_interaction(option: &CommandDataOption) -> Result<Self, ArgumentError> {
match option.value {
CommandOptionValue::Boolean(bool) => Ok(bool),
_ => unreachable!()
_ => unreachable!(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rowifi_models/src/analytics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use tokio_postgres::{types::Json, Error, Row};

use crate::roblox::id::GroupId;
Expand Down Expand Up @@ -35,4 +35,4 @@ impl TryFrom<Row> for AnalyticsGroup {
timestamp,
})
}
}
}
4 changes: 2 additions & 2 deletions rowifi_models/src/audit_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ pub enum AuditLogData {
},
EventTypeModify {
id: u32,
name: String
}
name: String,
},
}

impl TryFrom<tokio_postgres::Row> for AuditLog {
Expand Down
4 changes: 2 additions & 2 deletions rowifi_models/src/deny_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Serialize for DenyList {
let (user_id, group_id, code) = match &self.data {
DenyListData::User(u) => (Some(*u), None, None),
DenyListData::Group(g) => (None, Some(*g), None),
DenyListData::Custom(c) => (None, None, Some(c.clone()))
DenyListData::Custom(c) => (None, None, Some(c.clone())),
};
let intermediary = DenyListIntermediary {
id: self.id,
Expand All @@ -91,7 +91,7 @@ impl Serialize for DenyList {
action_type: self.action_type,
user_id,
group_id,
code
code,
};
intermediary.serialize(serializer)
}
Expand Down
4 changes: 3 additions & 1 deletion rowifi_models/src/roblox/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use tokio_postgres::types::{to_sql_checked, FromSql, IsNull, ToSql, Type};
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct AssetId(pub u64);

#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[derive(
Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize,
)]
pub struct GroupId(pub u64);

#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion rowifi_roblox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl RobloxClient {
if asset_filter.is_empty() {
return Ok(Vec::new());
}

let route = Route::ListInventoryItems {
user_id: user_id.0,
filter: asset_filter.build(),
Expand Down
3 changes: 2 additions & 1 deletion rowifi_roblox/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ impl Request {
pub fn build(mut self) -> Result<HyperRequest<Full<Bytes>>, hyper::http::Error> {
let original_uri = self.uri.unwrap_or_default();
let uri = if let Some(proxy_uri) = &self.proxy_uri {
self.proxy_params.insert("url".into(), urlencoding::encode(&original_uri).to_string());
self.proxy_params
.insert("url".into(), urlencoding::encode(&original_uri).to_string());
proxy_uri.clone()
} else {
original_uri
Expand Down

0 comments on commit 0e10898

Please sign in to comment.