diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/mod.rs | 4 | ||||
| -rw-r--r-- | src/commands/mod.rs | 1 | ||||
| -rw-r--r-- | src/commands/version.rs | 36 | ||||
| -rw-r--r-- | src/main.rs | 1 |
4 files changed, 41 insertions, 1 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs index 6224ab1..a1e0e97 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -3,9 +3,11 @@ use once_cell::sync::Lazy; pub mod guzzle; pub mod shiggy; +pub const USER_AGENT: &str = "teawieBot/0.1.0"; + pub static REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| { reqwest::Client::builder() - .user_agent("teawieBot/0.1.0") + .user_agent(USER_AGENT) .build() .unwrap_or_default() }); diff --git a/src/commands/mod.rs b/src/commands/mod.rs index fe536c1..d3a1b36 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -7,3 +7,4 @@ pub mod random_lore; pub mod random_shiggy; pub mod random_teawie; pub mod teawiespam; +pub mod version; diff --git a/src/commands/version.rs b/src/commands/version.rs new file mode 100644 index 0000000..54585b7 --- /dev/null +++ b/src/commands/version.rs @@ -0,0 +1,36 @@ +use crate::{Context, Error}; + +/// get version info +#[poise::command(slash_command)] +pub async fn version(ctx: Context<'_>) -> Result<(), Error> { + 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("Vesion Information") + .description("powered by poise!") + .fields(fields) + .color((136, 199, 253)) + }) + }) + .await?; + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index d4914e9..749daae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,6 +71,7 @@ async fn main() { random_teawie::random_teawie(), copypasta::copypasta(), teawiespam::teawiespam(), + version::version(), ], event_handler: |ctx, event, _, data| { Box::pin(async move { |
