diff --git a/src/commands/challenge.rs b/src/commands/challenge.rs index 0e5414f..b9e3089 100644 --- a/src/commands/challenge.rs +++ b/src/commands/challenge.rs @@ -1,15 +1,15 @@ +use crate::utils::*; +use serde_json::Map; use serenity::framework::standard::{macros::command, Args, CommandResult}; +use serenity::http::typing::Typing; use serenity::model::prelude::*; use serenity::prelude::*; -use serenity::http::typing::Typing; +use slug::slugify; use std::env; use std::fs; -use serde_json::Map; use std::fs::File; use std::io::Write; use std::path::Path; -use slug::slugify; -use crate::utils::*; #[command] async fn challenge(ctx: &Context, msg: &Message) -> CommandResult { diff --git a/src/commands/kanji.rs b/src/commands/kanji.rs index 3a1bce8..e292bb6 100644 --- a/src/commands/kanji.rs +++ b/src/commands/kanji.rs @@ -1,7 +1,7 @@ +use crate::utils::*; use serenity::framework::standard::{macros::command, Args, CommandResult}; use serenity::model::prelude::*; use serenity::prelude::*; -use crate::utils::*; #[command] async fn i(ctx: &Context, msg: &Message, args: Args) -> CommandResult { diff --git a/src/commands/meta.rs b/src/commands/meta.rs index 0bfc22b..c7be1eb 100644 --- a/src/commands/meta.rs +++ b/src/commands/meta.rs @@ -1,7 +1,7 @@ +use serenity::framework::standard::macros::hook; use serenity::framework::standard::{macros::command, CommandResult}; use serenity::model::prelude::*; use serenity::prelude::*; -use serenity::framework::standard::macros::hook; use std::env; @@ -40,4 +40,4 @@ pub async fn unrecognised_command_hook( unrecognised_command_name: &str, ) { msg.reply(&ctx.http, &format!("I don't understand the command '{}'. For a list of commands, see `{}help`. Commands are case-sensitive.", unrecognised_command_name, env::var("PREFIX").unwrap())).await.unwrap(); -} \ No newline at end of file +} diff --git a/src/commands/owner.rs b/src/commands/owner.rs index 9543b3e..431d67b 100644 --- a/src/commands/owner.rs +++ b/src/commands/owner.rs @@ -122,4 +122,4 @@ async fn rebuildSite(ctx: &Context, msg: &Message) -> CommandResult { msg.reply(&ctx.http, "Started site rebuild process!") .await?; Ok(()) -} \ No newline at end of file +} diff --git a/src/utils.rs b/src/utils.rs index 1082c54..56ffbf4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,16 +1,16 @@ +use rand::seq::IteratorRandom; +use serde_json::Map; +use serde_json::Value; use serenity::framework::standard::{Args, CommandResult}; use serenity::model::prelude::*; use serenity::prelude::*; +use std::env; use std::fs; -use serde_json::Map; -use serde_json::Value; use std::fs::File; use std::fs::OpenOptions; use std::io::Read; use std::io::Write; use std::process::Command; -use rand::seq::IteratorRandom; -use std::env; pub fn get_challenge_number() -> i32 { let challenge_dir = format!("{}/content/challenges", env::var("HUGO").unwrap()); @@ -107,7 +107,6 @@ pub fn rebuild_site() { .expect("Failed to rebuild site"); } - pub fn get_guild_data_path() -> String { env::var("GUILD_DATA").unwrap() } @@ -148,7 +147,13 @@ pub fn set_guild_data(guild_data: Map) { .unwrap(); } -pub async fn send(ctx: &Context, msg: &Message, message: &str, ping: bool, pin: bool) -> CommandResult { +pub async fn send( + ctx: &Context, + msg: &Message, + message: &str, + ping: bool, + pin: bool, +) -> CommandResult { let guild_data = get_guild_data(); let mut announcements_count = 0; for (_guild, data) in guild_data.iter() { @@ -211,8 +216,12 @@ pub fn get_so_diagram(kanji: char) -> String { ) } - -pub async fn display_kanji(ctx: &Context, msg: &Message, kanji: char, comment: &str) -> CommandResult { +pub async fn display_kanji( + ctx: &Context, + msg: &Message, + kanji: char, + comment: &str, +) -> CommandResult { msg.reply(&ctx.http, format!("{}{}", kanji, comment)) .await?; let url = get_so_diagram(kanji);