From 106b70d34884b7fa2c97ddb47da12c06b8e038b9 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 22 Sep 2024 18:20:58 +0200 Subject: [PATCH] add version command, v0.1.2 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/discord.rs | 2 ++ src/discord/commands.rs | 1 + src/discord/commands/version.rs | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/discord/commands/version.rs diff --git a/Cargo.lock b/Cargo.lock index b7f17ba..0b5ede9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -943,7 +943,7 @@ dependencies = [ [[package]] name = "mufbot-dc" -version = "0.1.1" +version = "0.1.2" dependencies = [ "chrono", "dotenv", diff --git a/Cargo.toml b/Cargo.toml index 1626956..1d2fef3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mufbot-dc" -version = "0.1.1" +version = "0.1.2" edition = "2021" license = "MIT" authors = ["gamersi "] diff --git a/src/discord.rs b/src/discord.rs index 9a95001..b832d57 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -36,12 +36,14 @@ pub async fn initiate_bot() { commands::buildlist::buildlist(), commands::shutdown::shutdown(), commands::restart::restart(), + commands::version::version(), ], ..Default::default() }) .setup(|ctx, _ready, framework| { Box::pin(async move { + poise::builtins::register_globally(ctx, &framework.options().commands).await?; let channel_id = serenity_prelude::ChannelId::new(crate::env::BOTS_CHANNEL_ID.parse().unwrap()); diff --git a/src/discord/commands.rs b/src/discord/commands.rs index c2d1d65..1d27152 100644 --- a/src/discord/commands.rs +++ b/src/discord/commands.rs @@ -3,6 +3,7 @@ pub mod buildlist; pub mod restart; pub mod rollout; pub mod shutdown; +pub mod version; use poise::serenity_prelude::futures::lock::Mutex; use std::sync::Arc; diff --git a/src/discord/commands/version.rs b/src/discord/commands/version.rs new file mode 100644 index 0000000..87a2ae6 --- /dev/null +++ b/src/discord/commands/version.rs @@ -0,0 +1,32 @@ +use poise::{ + serenity_prelude, CreateReply, +}; + +#[poise::command( + slash_command, + prefix_command +)] + +pub async fn version( + ctx: crate::discord::commands::Context<'_>, +) -> Result< + (), + crate::discord::commands::Error, +> { + + let version = + env!("CARGO_PKG_VERSION"); + + let embed = serenity_prelude::CreateEmbed::default() + .title("Version") + .description(format!("Current version: {}", version)) + .color(0x804fb3); + + let message = + CreateReply::default() + .embed(embed); + + ctx.send(message).await?; + + Ok(()) +}