|
|
@ -7,19 +7,34 @@ use std::fs;
|
|
|
|
|
|
|
|
|
|
|
|
#[command]
|
|
|
|
#[command]
|
|
|
|
async fn challenge(ctx: &Context, msg: &Message) -> CommandResult {
|
|
|
|
async fn challenge(ctx: &Context, msg: &Message) -> CommandResult {
|
|
|
|
println!("Command received");
|
|
|
|
println!("Command received");
|
|
|
|
let challenge_dir = env::var("CHALLENGE_DIR").unwrap();
|
|
|
|
let challenge_dir = env::var("CHALLENGE_DIR").unwrap();
|
|
|
|
let paths = fs::read_dir(challenge_dir).unwrap();
|
|
|
|
let paths = fs::read_dir(challenge_dir).unwrap();
|
|
|
|
let challenge = {
|
|
|
|
let challenge = {
|
|
|
|
let mut max = 0;
|
|
|
|
let mut max = 0;
|
|
|
|
for path in paths {
|
|
|
|
for path in paths {
|
|
|
|
let number = path.unwrap().path().file_stem().unwrap().to_str().unwrap().parse::<i32>().unwrap();
|
|
|
|
let number = path
|
|
|
|
if number > max {
|
|
|
|
.unwrap()
|
|
|
|
max = number;
|
|
|
|
.path()
|
|
|
|
}
|
|
|
|
.file_stem()
|
|
|
|
}
|
|
|
|
.unwrap()
|
|
|
|
max
|
|
|
|
.to_str()
|
|
|
|
};
|
|
|
|
.unwrap()
|
|
|
|
msg.reply(&ctx.http, format!("Tegaki Tuesday #{n}: https://tegakituesday.com/{n}", n = challenge)).await?;
|
|
|
|
.parse::<i32>()
|
|
|
|
Ok(())
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
if number > max {
|
|
|
|
|
|
|
|
max = number;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
max
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
msg.reply(
|
|
|
|
|
|
|
|
&ctx.http,
|
|
|
|
|
|
|
|
format!(
|
|
|
|
|
|
|
|
"Tegaki Tuesday #{n}: https://tegakituesday.com/{n}",
|
|
|
|
|
|
|
|
n = challenge
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|