summaryrefslogtreecommitdiff
path: root/src/commands/version.rs
blob: 8d9a1f30ff48722a253a3b6d71bf7ff7fb12bc63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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(())
}