diff --git a/src/commands/challenge.rs b/src/commands/challenge.rs index 3488411..30191bd 100644 --- a/src/commands/challenge.rs +++ b/src/commands/challenge.rs @@ -18,7 +18,7 @@ use slug::slugify; use crate::commands::owner::get_guild_data; -fn get_challenge_number() -> i32 { +pub fn get_challenge_number() -> i32 { let challenge_dir = format!("{}/content/challenges", env::var("HUGO").unwrap()); let paths = fs::read_dir(challenge_dir).unwrap(); let mut max = 0; diff --git a/src/commands/owner.rs b/src/commands/owner.rs index 03af18f..c064c90 100644 --- a/src/commands/owner.rs +++ b/src/commands/owner.rs @@ -9,8 +9,10 @@ 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; const GUILD_DATA_PATH: &str = "guilds.json"; @@ -160,4 +162,23 @@ async fn send(ctx: &Context, msg: &Message, message: &str, ping: bool, pin: bool #[owners_only] async fn announce(ctx: &Context, msg: &Message, args: Args) -> CommandResult { send(ctx, msg, args.rest(), true, true).await +} + +#[command] +#[owners_only] +async fn announceChallenge(ctx: &Context, msg: &Message) -> CommandResult { + let challenge_number = get_challenge_number(); + let message = format!("Welcome to the **{n}{th}** weekly **Tegaki Tuesday** (手書きの火曜日) handwriting challenge! :pen_fountain: The prompt is available in both Japanese and English on the website at . + +You can make submissions in both languages, but please submit in your target language first. Submissions can be submitted by uploading the image to this channel along with the `{p}submit` command. By submitting, you agree to having your work posted to the website under the Attribution-ShareAlike 4.0 Unported (CC BY-SA 4.0) license, attributed to your Discord account. ().", + n = challenge_number, + th = match challenge_number % 10 { + 1 => "ˢᵗ", + 2 => "ⁿᵈ", + 3 => "ʳᵈ", + _ => "ᵗʰ" + }, + p = env::var("PREFIX").unwrap() + ); + send(ctx, msg, &message, true, true).await } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index d11fe09..9e320b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,8 @@ impl EventHandler for Handler { sleep, setSubmissionChannel, setAnnouncementRole, - announce + announce, + announceChallenge )] struct General;