From 4e92771f8f227667ab82dee902b79f5633a0ff1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Czy=C5=BC?= Date: Sun, 18 Feb 2024 19:28:46 +0100 Subject: [PATCH] minor refractors, uptime removed --- src/commands/music.rs | 1 - src/commands/music/soundboard.rs | 14 ++++-------- src/commands/music/soundboard/effect.rs | 11 +++++++++ src/commands/music/soundboard/override.rs | 0 src/commands/music/soundboard/stream.rs | 11 +++++++++ src/commands/tools.rs | 4 ++-- src/commands/tools/uptime.rs | 27 +++++++++++++++++++++-- src/main.rs | 5 +++-- 8 files changed, 56 insertions(+), 17 deletions(-) delete mode 100644 src/commands/music/soundboard/override.rs create mode 100644 src/commands/music/soundboard/stream.rs diff --git a/src/commands/music.rs b/src/commands/music.rs index 5c7c189..ac554aa 100644 --- a/src/commands/music.rs +++ b/src/commands/music.rs @@ -28,6 +28,5 @@ pub use resume::resume; pub use seek::seek; pub use shuffle::shuffle; pub use skip::skip; -pub use soundboard::soundboard; pub use stop::stop; pub use volume::volume; diff --git a/src/commands/music/soundboard.rs b/src/commands/music/soundboard.rs index e0ae2f6..220fc0d 100644 --- a/src/commands/music/soundboard.rs +++ b/src/commands/music/soundboard.rs @@ -1,11 +1,5 @@ -use crate::{commands::embeds::embed, Context, Error}; -use poise::CreateReply; +pub mod effect; +pub mod stream; -/// A better soundboard -#[poise::command(prefix_command, slash_command, category = "Music")] -pub async fn soundboard(ctx: Context<'_>) -> Result<(), Error> { - ctx.send(CreateReply::default().embed(embed(ctx, "", "", "").await.unwrap())) - .await?; - - Ok(()) -} +pub use effect::effect; +pub use stream::stream; diff --git a/src/commands/music/soundboard/effect.rs b/src/commands/music/soundboard/effect.rs index e69de29..f0c8ff9 100644 --- a/src/commands/music/soundboard/effect.rs +++ b/src/commands/music/soundboard/effect.rs @@ -0,0 +1,11 @@ +use crate::{commands::embeds::embed, Context, Error}; +use poise::CreateReply; + +/// Plays one of available audio effects +#[poise::command(prefix_command, slash_command, category = "Music")] +pub async fn effect(ctx: Context<'_>) -> Result<(), Error> { + ctx.send(CreateReply::default().embed(embed(ctx, "Playing an effect", "", "").await.unwrap())) + .await?; + + Ok(()) +} diff --git a/src/commands/music/soundboard/override.rs b/src/commands/music/soundboard/override.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/commands/music/soundboard/stream.rs b/src/commands/music/soundboard/stream.rs new file mode 100644 index 0000000..f97747c --- /dev/null +++ b/src/commands/music/soundboard/stream.rs @@ -0,0 +1,11 @@ +use crate::{commands::embeds::embed, Context, Error}; +use poise::CreateReply; + +/// Hijacks current audio output and plays selected audio +#[poise::command(prefix_command, slash_command, aliases("override"), category = "Music")] +pub async fn stream(ctx: Context<'_>) -> Result<(), Error> { + ctx.send(CreateReply::default().embed(embed(ctx, "Playing audio", "", "").await.unwrap())) + .await?; + + Ok(()) +} diff --git a/src/commands/tools.rs b/src/commands/tools.rs index 40721f2..495cdaa 100644 --- a/src/commands/tools.rs +++ b/src/commands/tools.rs @@ -10,7 +10,7 @@ pub mod posix; pub mod qr; pub mod register; pub mod taf; -pub mod uptime; +// pub mod uptime; pub mod verse; pub mod weather; @@ -26,6 +26,6 @@ pub use posix::posix; pub use qr::qr; pub use register::register; pub use taf::taf; -pub use uptime::uptime; +// pub use uptime::uptime; pub use verse::verse; pub use weather::weather; diff --git a/src/commands/tools/uptime.rs b/src/commands/tools/uptime.rs index 975eaf4..0cef651 100644 --- a/src/commands/tools/uptime.rs +++ b/src/commands/tools/uptime.rs @@ -2,11 +2,34 @@ use poise::CreateReply; use crate::{commands::embeds::embed, Context, Error}; +// Currently unable to get information on how long the thread was running. +const PROCESS_UPTIME: i64 = 1000; + /// Checks how long the bot has been running #[poise::command(prefix_command, slash_command, category = "Tools")] pub async fn uptime(ctx: Context<'_>) -> Result<(), Error> { - ctx.send(CreateReply::default().embed(embed(ctx, "", "", "").await.unwrap())) - .await?; + let uptime = PROCESS_UPTIME; + let days = uptime / (24 * 60 * 60); + let hours = (uptime % (24 * 60 * 60)) / 3600; + let minutes = (uptime % 60 * 60) / 60; + let seconds = uptime % 60; + + ctx.send( + CreateReply::default().embed( + embed( + ctx, + "I have been up and awake for", + &format!("{} seconds", uptime), + &format!( + "{} days, {} hours, {} minutes and {} seconds", + days, hours, minutes, seconds + ), + ) + .await + .unwrap(), + ), + ) + .await?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index afc3cfa..df775bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,9 +55,10 @@ async fn main() { music::seek(), music::shuffle(), music::skip(), - music::soundboard(), music::stop(), music::volume(), + music::soundboard::effect(), + music::soundboard::stream(), tools::ai(), tools::dice(), tools::dictionary(), @@ -70,7 +71,7 @@ async fn main() { tools::qr(), tools::register(), tools::taf(), - tools::uptime(), + // tools::uptime(), tools::verse(), tools::weather(), ];