summaryrefslogtreecommitdiff
path: root/src/commands/general/version.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/general/version.rs')
-rw-r--r--src/commands/general/version.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/commands/general/version.rs b/src/commands/general/version.rs
new file mode 100644
index 0000000..8b8d1f1
--- /dev/null
+++ b/src/commands/general/version.rs
@@ -0,0 +1,38 @@
+use crate::colors::Colors;
+use crate::Context;
+use color_eyre::eyre::Result;
+
+/// get version info
+#[poise::command(slash_command)]
+pub async fn version(ctx: Context<'_>) -> Result<()> {
+ let sha = option_env!("GIT_SHA").unwrap_or("main");
+
+ let revision_url = format!(
+ "[{}]({}/tree/{})",
+ sha,
+ option_env!("CARGO_PKG_REPOSITORY").unwrap_or("https://github.com/getchoo/teawieBot"),
+ sha,
+ );
+
+ let fields = [
+ (
+ "Version:",
+ option_env!("CARGO_PKG_VERSION").unwrap_or("not found"),
+ false,
+ ),
+ ("Revision:", &revision_url, false),
+ ("User Agent:", &crate::api::USER_AGENT, false),
+ ];
+
+ ctx.send(|c| {
+ c.embed(|e| {
+ e.title("Version Information")
+ .description("powered by poise!")
+ .fields(fields)
+ .color(Colors::Blue)
+ })
+ })
+ .await?;
+
+ Ok(())
+}