From 49f41d0770892bf654a25cc19e8591c8326a7b52 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sun, 27 Feb 2022 16:23:11 -0800 Subject: [PATCH] Move rebuildSite command into owner.rs --- src/commands/challenge.rs | 28 +--------------------------- src/commands/owner.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/commands/challenge.rs b/src/commands/challenge.rs index 7a09707..dd53755 100644 --- a/src/commands/challenge.rs +++ b/src/commands/challenge.rs @@ -107,39 +107,13 @@ fn to_fullwidth(string: &str) -> String { fullwidth } -fn rebuild_site() { +pub fn rebuild_site() { Command::new("./build.sh") .current_dir(get_hugo_path()) .spawn() .expect("Failed to rebuild site"); } -#[command] -#[owners_only] -#[allow(non_snake_case)] -async fn rebuildSite(ctx: &Context, msg: &Message) -> CommandResult { - rebuild_site(); - msg.reply(&ctx.http, "Started site rebuild process!") - .await?; - Ok(()) -} - -#[command] -#[owners_only] -#[allow(non_snake_case)] -async fn pullAndRebuildSite(ctx: &Context, msg: &Message) -> CommandResult { - Command::new("git") - .current_dir(get_hugo_path()) - .arg("pull") - .spawn() - .expect("Failed to git pull") - .wait()?; - rebuild_site(); - msg.reply(&ctx.http, "Pulled and started site rebuild process!") - .await?; - Ok(()) -} - #[command] async fn challenge(ctx: &Context, msg: &Message) -> CommandResult { msg.reply( diff --git a/src/commands/owner.rs b/src/commands/owner.rs index 5ebf274..de125e8 100644 --- a/src/commands/owner.rs +++ b/src/commands/owner.rs @@ -12,6 +12,7 @@ use std::io::Read; use std::io::Write; use crate::commands::challenge::get_challenge_number; +use crate::commands::challenge::rebuild_site; use crate::ShardManagerContainer; fn get_guild_data_path() -> String { @@ -211,3 +212,13 @@ You can make submissions in both languages, but please submit in your target lan ); send(ctx, msg, &message, true, true).await } + +#[command] +#[owners_only] +#[allow(non_snake_case)] +async fn rebuildSite(ctx: &Context, msg: &Message) -> CommandResult { + rebuild_site(); + msg.reply(&ctx.http, "Started site rebuild process!") + .await?; + Ok(()) +} \ No newline at end of file