diff --git a/.gitignore b/.gitignore index fedaa2b..3d62c7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target .env + diff --git a/Cargo.lock b/Cargo.lock index 059ef6c..a7ec76f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,6 +124,21 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -476,6 +491,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "fancy-regex" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" +dependencies = [ + "bit-set", + "regex-automata 0.4.5", + "regex-syntax 0.8.2", +] + [[package]] name = "fastrand" version = "2.0.1" @@ -936,6 +962,7 @@ name = "lyra" version = "0.4.0" dependencies = [ "dotenv", + "fancy-regex", "openssl", "poise", "regex", @@ -2067,10 +2094,14 @@ checksum = "62e48dba70095f265fdb269b99619b95d04c89e619538138383e63310b14d941" dependencies = [ "lazy_static", "symphonia-bundle-flac", + "symphonia-bundle-mp3", + "symphonia-codec-aac", "symphonia-codec-adpcm", + "symphonia-codec-alac", "symphonia-codec-pcm", "symphonia-codec-vorbis", "symphonia-core", + "symphonia-format-isomp4", "symphonia-format-mkv", "symphonia-format-ogg", "symphonia-format-wav", @@ -2089,6 +2120,30 @@ dependencies = [ "symphonia-utils-xiph", ] +[[package]] +name = "symphonia-bundle-mp3" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f31d7fece546f1e6973011a9eceae948133bbd18fd3d52f6073b1e38ae6368a" +dependencies = [ + "bitflags 1.3.2", + "lazy_static", + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-codec-aac" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bdd75b25ce4b84b12a4bd20bfea2460c2dbd7fc1d227ef5533504d3168109d" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", +] + [[package]] name = "symphonia-codec-adpcm" version = "0.5.3" @@ -2099,6 +2154,16 @@ dependencies = [ "symphonia-core", ] +[[package]] +name = "symphonia-codec-alac" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a27e8763d1c9eff666faf903e73a99d4de2f7a93fca4e3c214c1d68432903b9" +dependencies = [ + "log", + "symphonia-core", +] + [[package]] name = "symphonia-codec-pcm" version = "0.5.3" @@ -2133,6 +2198,19 @@ dependencies = [ "log", ] +[[package]] +name = "symphonia-format-isomp4" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf14bae5cf352032416bc64151e5d6242d29d33cbf3238513b44d4427a1efb" +dependencies = [ + "encoding_rs", + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + [[package]] name = "symphonia-format-mkv" version = "0.5.3" diff --git a/Cargo.toml b/Cargo.toml index f305a5c..016f83b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,14 @@ keywords = ["discord", "bot", "rust", "music", "featureful"] [dependencies] dotenv = "0.15.0" +fancy-regex = "0.13.0" openssl = { version = "0.10.63", features = ["vendored"] } poise = "0.6.1" regex = "1.10.3" reqwest = "0.11.23" serenity = { version = "0.12.0", features = ["cache", "framework", "standard_framework", "voice"] } songbird = { version = "0.4.0", features = ["builtin-queue", "serenity"] } -symphonia = "0.5.3" +symphonia = { version = "0.5.3", features = ["aac", "adpcm", "alac", "flac", "mpa", "isomp4"] } tokio = { version = "1.35.1", features = ["macros", "full", "signal"] } tracing = "0.1.40" tracing-futures = "0.2.5" diff --git a/src/commands/mod.rs b/src/commands/mod.rs deleted file mode 100644 index 08f5ddf..0000000 --- a/src/commands/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod kashi; -pub mod music; -pub mod tools; diff --git a/src/main.rs b/src/main.rs index 7911ef2..13ed9c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,36 +1,18 @@ -use songbird::SerenityInit; - -use poise::serenity_prelude::{self as serenity, ActivityData}; use std::sync::Arc; use std::time::Duration; use tracing::{info, warn, error}; +use poise::serenity_prelude::{self as serenity, ActivityData}; +use songbird::SerenityInit; use reqwest::Client as HttpClient; -mod http; mod commands; +mod http; -// http typemap for handling requests +use crate::commands::kashi; +use crate::commands::music; +use crate::commands::tools; use crate::http::HttpKey; -// commands: music -use crate::commands::music::deafen::*; -use crate::commands::music::join::*; -use crate::commands::music::leave::*; -use crate::commands::music::mute::*; -use crate::commands::music::play::*; -use crate::commands::music::queue::*; -use crate::commands::music::skip::*; -use crate::commands::music::stop::*; -use crate::commands::music::repeat::*; -use crate::commands::music::pause::*; -use crate::commands::music::resume::*; - -// commands: tools -use crate::commands::tools::ping::*; - -// commands: kashi -use crate::commands::kashi::kashi::*; - type Error = Box; type Context<'a> = poise::Context<'a, Data, Error>; @@ -50,16 +32,8 @@ async fn on_error(error: poise::FrameworkError<'_, Data, Error>) { } } -// this is for debug only -#[poise::command(prefix_command)] -pub async fn register(ctx: Context<'_>) -> Result<(), Error> { - poise::builtins::register_application_commands_buttons(ctx).await?; - Ok(()) -} - #[tokio::main] async fn main() { - // logger and dotenv initialization tracing_subscriber::fmt::init(); dotenv::dotenv().expect("Failed to load .env file."); @@ -67,24 +41,20 @@ async fn main() { let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!"); let commands = vec![ - // commands: music - deafen(), - join(), - leave(), - repeat(), - mute(), - pause(), - play(), - queue(), - resume(), - skip(), - stop(), - // commands: tools - ping(), - // commands: kashi - kashi(), - // commands: debug - register(), + kashi::kashi(), + music::deafen(), + music::join(), + music::leave(), + music::repeat(), + music::mute(), + music::pause(), + music::play(), + music::queue(), + music::resume(), + music::skip(), + music::stop(), + tools::ping(), + tools::register(), ]; let options = poise::FrameworkOptions {