Add announceChallenge command

late-submissions
Elnu 2 years ago
parent 91198ab35e
commit 0741d18c48

@ -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;

@ -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 <https://tegakituesday/{n}>.
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. (<https://creativecommons.org/licenses/by-sa/4.0>).",
n = challenge_number,
th = match challenge_number % 10 {
1 => "ˢᵗ",
2 => "ⁿᵈ",
3 => "ʳᵈ",
_ => "ᵗʰ"
},
p = env::var("PREFIX").unwrap()
);
send(ctx, msg, &message, true, true).await
}

@ -58,7 +58,8 @@ impl EventHandler for Handler {
sleep,
setSubmissionChannel,
setAnnouncementRole,
announce
announce,
announceChallenge
)]
struct General;

Loading…
Cancel
Save