diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d569cbb --- /dev/null +++ b/build.rs @@ -0,0 +1,15 @@ +use std::process::Command; + +fn main() { + // get + let output = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output() + .expect("git rev-parse HEAD failed"); + let hash = String::from_utf8(output.stdout).expect("not UTF-8 output"); + + let output = Command::new("git").args(&["rev-parse", "--abbrev-ref", "HEAD"]).output() + .expect("git rev-parse HEAD failed"); + let branch = String::from_utf8(output.stdout).expect("not UTF-8 output"); + + println!("cargo:rustc-env=GIT_HASH={}", hash); + println!("cargo:rustc-env=GIT_BRANCH={}", branch); +} \ No newline at end of file diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 54e3cd2..4907154 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -7,6 +7,7 @@ mod gambling; mod eval; pub mod self_roles; mod settings; +mod version; use crate::common::{Data, Error, Context}; @@ -35,5 +36,6 @@ pub fn commands() -> Vec> { eval::eval(), self_roles::role(), settings::setting(), + version::version(), ] } diff --git a/src/commands/version.rs b/src/commands/version.rs new file mode 100644 index 0000000..d8f4781 --- /dev/null +++ b/src/commands/version.rs @@ -0,0 +1,8 @@ +use crate::common::{Context, Error}; + +/// Tells you the current version of BigBirb +#[poise::command(slash_command, prefix_command)] +pub async fn version(ctx: Context<'_>) -> Result<(), Error> { + ctx.reply(format!("version {} ({}/{})", env!("CARGO_PKG_VERSION"), env!("GIT_BRANCH"), env!("GIT_HASH"))).await?; + Ok(()) +}