Skip to content

Commit 106b70d

Browse files
committed
add version command, v0.1.2
1 parent 88a5d03 commit 106b70d

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mufbot-dc"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
license = "MIT"
66
authors = ["gamersi <[email protected]>"]

src/discord.rs

+2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ pub async fn initiate_bot() {
3636
commands::buildlist::buildlist(),
3737
commands::shutdown::shutdown(),
3838
commands::restart::restart(),
39+
commands::version::version(),
3940
],
4041
..Default::default()
4142
})
4243
.setup(|ctx, _ready, framework| {
4344

4445
Box::pin(async move {
46+
4547
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
4648

4749
let channel_id = serenity_prelude::ChannelId::new(crate::env::BOTS_CHANNEL_ID.parse().unwrap());

src/discord/commands.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub mod buildlist;
33
pub mod restart;
44
pub mod rollout;
55
pub mod shutdown;
6+
pub mod version;
67

78
use poise::serenity_prelude::futures::lock::Mutex;
89
use std::sync::Arc;

src/discord/commands/version.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use poise::{
2+
serenity_prelude, CreateReply,
3+
};
4+
5+
#[poise::command(
6+
slash_command,
7+
prefix_command
8+
)]
9+
10+
pub async fn version(
11+
ctx: crate::discord::commands::Context<'_>,
12+
) -> Result<
13+
(),
14+
crate::discord::commands::Error,
15+
> {
16+
17+
let version =
18+
env!("CARGO_PKG_VERSION");
19+
20+
let embed = serenity_prelude::CreateEmbed::default()
21+
.title("Version")
22+
.description(format!("Current version: {}", version))
23+
.color(0x804fb3);
24+
25+
let message =
26+
CreateReply::default()
27+
.embed(embed);
28+
29+
ctx.send(message).await?;
30+
31+
Ok(())
32+
}

0 commit comments

Comments
 (0)