From 38318687dc2c7875f39e07f204e6fc0ac9b77ed2 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 19 Feb 2022 11:07:52 -0800 Subject: [PATCH] cargo fmt --- src/commands/challenge.rs | 15 +++++++++--- src/commands/owner.rs | 51 +++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/commands/challenge.rs b/src/commands/challenge.rs index 01ef962..378af13 100644 --- a/src/commands/challenge.rs +++ b/src/commands/challenge.rs @@ -118,7 +118,8 @@ fn rebuild_site() { #[allow(non_snake_case)] async fn rebuildSite(ctx: &Context, msg: &Message) -> CommandResult { rebuild_site(); - msg.reply(&ctx.http, "Started site rebuild process!").await?; + msg.reply(&ctx.http, "Started site rebuild process!") + .await?; Ok(()) } @@ -133,7 +134,8 @@ async fn pullAndRebuildSite(ctx: &Context, msg: &Message) -> CommandResult { .expect("Failed to git pull") .wait()?; rebuild_site(); - msg.reply(&ctx.http, "Pulled and started site rebuild process!").await?; + msg.reply(&ctx.http, "Pulled and started site rebuild process!") + .await?; Ok(()) } @@ -156,9 +158,14 @@ async fn submit(ctx: &Context, msg: &Message) -> CommandResult { // there are large duplicated sections that need to be merged somehow. let guild_data = get_guild_data(); let guild = msg.guild_id.unwrap().as_u64().to_string(); - if !guild_data.contains_key(&guild) || !&guild_data[&guild].as_object().unwrap().contains_key("submissionChannel") { + if !guild_data.contains_key(&guild) + || !&guild_data[&guild] + .as_object() + .unwrap() + .contains_key("submissionChannel") + { msg.reply(&ctx.http, "Submissions aren't enabled for this server yet.") - .await?; + .await?; return Ok(()); } let current_guild_data = &guild_data[&guild].as_object().unwrap(); diff --git a/src/commands/owner.rs b/src/commands/owner.rs index 2f21c64..d6aced0 100644 --- a/src/commands/owner.rs +++ b/src/commands/owner.rs @@ -5,14 +5,14 @@ use serenity::prelude::*; use serde_json::json; use serde_json::Map; use serde_json::Value; +use std::env; use std::fs::File; use std::fs::OpenOptions; use std::io::Read; use std::io::Write; -use std::env; -use crate::ShardManagerContainer; use crate::commands::challenge::get_challenge_number; +use crate::ShardManagerContainer; fn get_guild_data_path() -> String { env::var("GUILD_DATA").unwrap() @@ -93,7 +93,11 @@ async fn setSubmissionChannel(ctx: &Context, msg: &Message) -> CommandResult { set_guild_data(guild_data); msg.reply( &ctx.http, - format!("Submission channel for **{}** set to <#{}>.", msg.guild(&ctx).await.unwrap().name, msg.channel_id), + format!( + "Submission channel for **{}** set to <#{}>.", + msg.guild(&ctx).await.unwrap().name, + msg.channel_id + ), ) .await?; Ok(()) @@ -107,7 +111,8 @@ async fn setAnnouncementRole(ctx: &Context, msg: &Message, mut args: Args) -> Co match args.single::() { Ok(id) => role = id.to_string(), Err(_) => { - msg.reply(&ctx.http, "Please provide an announcement role ID.").await?; + msg.reply(&ctx.http, "Please provide an announcement role ID.") + .await?; return Ok(()); } } @@ -137,27 +142,47 @@ async fn send(ctx: &Context, msg: &Message, message: &str, ping: bool, pin: bool if !data.contains_key("submissionChannel") { continue; } - let channel = ChannelId(data["submissionChannel"].as_str().unwrap().parse::().unwrap()); + let channel = ChannelId( + data["submissionChannel"] + .as_str() + .unwrap() + .parse::() + .unwrap(), + ); let mut message_to_send = String::from(""); if ping && data.contains_key("announcementRole") { - message_to_send.push_str(&format!("<@&{}> ", data["announcementRole"].as_str().unwrap())); + message_to_send.push_str(&format!( + "<@&{}> ", + data["announcementRole"].as_str().unwrap() + )); } message_to_send.push_str(message); - let sent_message = channel.send_message(&ctx.http, |e| { - e.content(message_to_send); - e - }).await.unwrap(); + let sent_message = channel + .send_message(&ctx.http, |e| { + e.content(message_to_send); + e + }) + .await + .unwrap(); if pin { // No need to do anything on error, // it just means we don't have pin permissions match sent_message.pin(&ctx.http).await { Ok(_) => (), - Err(_) => () + Err(_) => (), }; } announcements_count += 1; } - msg.reply(&ctx.http, format!("Announced to {} server{}!", announcements_count, if announcements_count == 1 { "" } else { "s" })).await?; + msg.reply( + &ctx.http, + format!( + "Announced to {} server{}!", + announcements_count, + if announcements_count == 1 { "" } else { "s" } + ), + ) + .await?; Ok(()) } @@ -185,4 +210,4 @@ You can make submissions in both languages, but please submit in your target lan p = env::var("PREFIX").unwrap() ); send(ctx, msg, &message, true, true).await -} \ No newline at end of file +}