diff --git a/.gitmodules b/.gitmodules index 9261d5d..1c4fa95 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "libs/serenity"] path = libs/serenity url = git@github.com:eRgo35/serenity.git +[submodule "libs/poise"] + path = libs/poise + url = git@github.com:eRgo35/poise.git diff --git a/Cargo.lock b/Cargo.lock index 73cda35..486d33c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,8 +294,6 @@ dependencies = [ [[package]] name = "command_attr" version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88da8d7e9fe6f30d8e3fcf72d0f84102b49de70fece952633e8439e89bdc7631" dependencies = [ "proc-macro2", "quote", @@ -1349,7 +1347,7 @@ dependencies = [ [[package]] name = "lyra" -version = "0.9.0" +version = "0.9.1" dependencies = [ "dotenv", "fancy-regex", @@ -1364,7 +1362,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "serenity", + "serenity 0.12.2", "songbird", "symphonia", "tokio", @@ -1863,25 +1861,23 @@ dependencies = [ [[package]] name = "poise" version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1819d5a45e3590ef33754abce46432570c54a120798bdbf893112b4211fa09a6" dependencies = [ "async-trait", "derivative", "futures-util", + "indexmap", "parking_lot", "poise_macros", "regex", - "serenity", + "serenity 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio", "tracing", + "trim-in-place", ] [[package]] name = "poise_macros" version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fa2c123c961e78315cd3deac7663177f12be4460f5440dbf62a7ed37b1effea" dependencies = [ "darling 0.20.10", "proc-macro2", @@ -2683,8 +2679,6 @@ dependencies = [ [[package]] name = "serenity" version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "880a04106592d0a8f5bdacb1d935889bfbccb4a14f7074984d9cd857235d34ac" dependencies = [ "arrayvec", "async-trait", @@ -2717,11 +2711,43 @@ dependencies = [ "uwl", ] +[[package]] +name = "serenity" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "880a04106592d0a8f5bdacb1d935889bfbccb4a14f7074984d9cd857235d34ac" +dependencies = [ + "arrayvec", + "async-trait", + "base64 0.22.1", + "bitflags 2.6.0", + "bytes", + "chrono", + "dashmap", + "flate2", + "futures", + "fxhash", + "mime_guess", + "parking_lot", + "percent-encoding", + "reqwest 0.11.27", + "secrecy", + "serde", + "serde_cow", + "serde_json", + "time", + "tokio", + "tokio-tungstenite 0.21.0", + "tracing", + "typemap_rev", + "typesize", + "url", +] + [[package]] name = "serenity-voice-model" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "593682f6155d07c8b331b3d1060f5aab7e6796caca9f2f66bd9e6855c880e06b" +source = "git+https://github.com/serenity-rs/serenity?branch=current#658b6a7261fbde7cf59f84613f870ef7a48735c6" dependencies = [ "bitflags 2.6.0", "num-traits", @@ -2852,7 +2878,7 @@ dependencies = [ "serde", "serde-aux", "serde_json", - "serenity", + "serenity 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "serenity-voice-model", "socket2", "stream_lib", @@ -3585,6 +3611,12 @@ dependencies = [ "strength_reduce", ] +[[package]] +name = "trim-in-place" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" + [[package]] name = "triomphe" version = "0.1.13" diff --git a/Cargo.toml b/Cargo.toml index d63af08..f025c74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lyra" -version = "0.9.0" +version = "0.9.1" authors = ["Michał Czyż "] edition = "2021" description = "A featureful Discord bot written in Rust." @@ -11,19 +11,19 @@ license-file = "LICENSE.md" keywords = ["discord", "bot", "rust", "music", "featureful"] [dependencies] -lib-spotify-parser = { path = "libs/spotify-parser" } +lib-spotify-parser = { path = "./libs/spotify-parser" } dotenv = "0.15.0" fancy-regex = "0.13.0" json = "0.12.4" openssl = { version = "0.10.66", features = ["vendored"] } owoify = "0.1.5" -poise = "0.6.1" +poise = { path = "./libs/poise", default-features = true, version = "0.6.1" } rand = "0.8.5" regex = "1.10.6" reqwest = { version = "0.11.27", features = ["json"] } serde = { version = "1.0.204", features = ["derive"] } serde_json = "1.0.122" -songbird = { path = "./libs/songbird", version = "0.4", default-features = true, features = [ +songbird = { path = "./libs/songbird", version = "0.4.3", default-features = true, features = [ "builtin-queue", ] } serenity = { path = "./libs/serenity", default-features = true, features = [ @@ -49,3 +49,7 @@ tracing-futures = "0.2.5" tracing-subscriber = "0.3.18" url = "2.5.2" once_cell = "1.19.0" + +[patch.crates-io.serenity-voice-model] +git = "https://github.com/serenity-rs/serenity" +branch = "current" diff --git a/libs/poise b/libs/poise new file mode 160000 index 0000000..5750259 --- /dev/null +++ b/libs/poise @@ -0,0 +1 @@ +Subproject commit 575025909b063c3b998659abf9d241c8790404ee diff --git a/src/commands/embeds.rs b/src/commands/embeds.rs index 6a5a825..668ab4d 100644 --- a/src/commands/embeds.rs +++ b/src/commands/embeds.rs @@ -1,11 +1,9 @@ use crate::{Context, Error}; -use poise::serenity_prelude::CreateEmbed; -use poise::CreateReply; -use serenity::{ - builder::{CreateEmbedAuthor, CreateEmbedFooter}, - model::{Colour, Timestamp}, +use poise::serenity_prelude::{ + Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp, }; +use poise::CreateReply; pub async fn fail(ctx: Context<'_>, err: String) -> Result<(), Error> { ctx.send( @@ -25,7 +23,7 @@ pub async fn error_embed(ctx: Context<'_>, msg: &str) -> Result Result { let embed = CreateEmbed::default() .author(CreateEmbedAuthor::new(author).icon_url(ctx.author().clone().face())) - .colour(Colour::from_rgb(255, 58, 97)) + .colour(Color::from_rgb(255, 58, 97)) .title(title) .description(description) .timestamp(Timestamp::now()) diff --git a/src/commands/music/play.rs b/src/commands/music/play.rs index 7c10503..b2f779b 100644 --- a/src/commands/music/play.rs +++ b/src/commands/music/play.rs @@ -3,13 +3,11 @@ use crate::{commands::embeds::error_embed, Context, Error}; use fancy_regex::Regex; use lib_spotify_parser; -use poise::serenity_prelude::model::Timestamp; -use poise::serenity_prelude::Colour; -use poise::serenity_prelude::CreateEmbed; +use poise::serenity_prelude::{ + Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp, +}; use poise::CreateReply; use regex::Regex as Regex_Classic; -use serenity::builder::CreateEmbedAuthor; -use serenity::builder::CreateEmbedFooter; use songbird::events::TrackEvent; use songbird::input::AuxMetadata; use songbird::input::{Compose, YoutubeDl}; @@ -212,7 +210,7 @@ async fn generate_embed( let embed = CreateEmbed::default() .author(CreateEmbedAuthor::new("Track enqueued").icon_url(ctx.author().clone().face())) - .colour(Colour::from_rgb(255, 58, 97)) + .colour(Color::from_rgb(255, 58, 97)) .title(title.unwrap()) .url(source_url.unwrap()) .thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face())) @@ -260,7 +258,7 @@ async fn generate_playlist_embed( let embed = CreateEmbed::default() .author(CreateEmbedAuthor::new("Playlist enqueued").icon_url(ctx.author().clone().face())) - .colour(Colour::from_rgb(255, 58, 97)) + .colour(Color::from_rgb(255, 58, 97)) .title(title.as_ref().unwrap()) .url(source_url.as_ref().unwrap()) .thumbnail( diff --git a/src/commands/music/queue.rs b/src/commands/music/queue.rs index f42b1f0..e3ba012 100644 --- a/src/commands/music/queue.rs +++ b/src/commands/music/queue.rs @@ -2,12 +2,10 @@ use std::time::Duration; use crate::commands::music::metadata::Metadata; use crate::{commands::embeds::error_embed, Context, Error}; -use poise::serenity_prelude::CreateEmbed; -use poise::CreateReply; -use serenity::{ - builder::{CreateEmbedAuthor, CreateEmbedFooter}, - model::{Colour, Timestamp}, +use poise::serenity_prelude::{ + Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp, }; +use poise::CreateReply; use songbird::input::AuxMetadata; const QUEUE_DISPLAY_LENGTH: usize = 10; @@ -80,7 +78,7 @@ async fn embed(ctx: Context<'_>, queue: String) -> Result { let embed = CreateEmbed::default() .author(CreateEmbedAuthor::new("Queue").icon_url(ctx.author().clone().face())) - .colour(Colour::from_rgb(255, 58, 97)) + .colour(Color::from_rgb(255, 58, 97)) .title(title) .description(queue) .timestamp(timestamp) diff --git a/src/commands/music/skip.rs b/src/commands/music/skip.rs index 8c8874b..bc4f9c6 100644 --- a/src/commands/music/skip.rs +++ b/src/commands/music/skip.rs @@ -5,21 +5,15 @@ use crate::{ commands::embeds::{embed, error_embed}, Context, Error, }; -use poise::CreateReply; -use serenity::{ - builder::{CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter}, - model::{Colour, Timestamp}, +use poise::serenity_prelude::{ + Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp, }; +use poise::CreateReply; use songbird::{input::AuxMetadata, tracks::TrackHandle}; /// Skips the currently playing song; \ /// aliases: skip, :skipper: -#[poise::command( - prefix_command, - slash_command, - aliases("skipper:"), - category = "Music" -)] +#[poise::command(prefix_command, slash_command, aliases("skipper:"), category = "Music")] pub async fn skip(ctx: Context<'_>) -> Result<(), Error> { let guild_id = ctx.guild_id().unwrap(); @@ -88,7 +82,7 @@ async fn generate_embed( let embed = CreateEmbed::default() .author(CreateEmbedAuthor::new("Skipped!").icon_url(ctx.author().clone().face())) - .colour(Colour::from_rgb(255, 58, 97)) + .colour(Color::from_rgb(255, 58, 97)) .title(title.as_ref().unwrap()) .url(source_url.as_ref().unwrap()) .thumbnail( diff --git a/src/commands/music/soundboard/effect.rs b/src/commands/music/soundboard/effect.rs index 0ffdf95..ab354b0 100644 --- a/src/commands/music/soundboard/effect.rs +++ b/src/commands/music/soundboard/effect.rs @@ -1,11 +1,9 @@ use crate::{commands::embeds::error_embed, Context, Error}; -use poise::serenity_prelude::model::Timestamp; -use poise::serenity_prelude::Colour; -use poise::serenity_prelude::CreateEmbed; +use poise::serenity_prelude::{ + Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp, +}; use poise::CreateReply; -use serenity::builder::CreateEmbedAuthor; -use serenity::builder::CreateEmbedFooter; use songbird::events::TrackEvent; use songbird::input::AuxMetadata; use songbird::input::{Compose, YoutubeDl}; @@ -91,7 +89,7 @@ async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result, src: YoutubeDl) -> Result, message: String) -> Result> = /// Checks how long the bot has been running #[poise::command(prefix_command, slash_command, category = "Tools")] pub async fn uptime(ctx: Context<'_>) -> Result<(), Error> { - let start = PROCESS_UPTIME.lock().unwrap().clone(); + let start = *PROCESS_UPTIME.lock().unwrap(); let uptime = std::time::SystemTime::now().duration_since(start).unwrap(); let (days, hours, minutes, seconds) = ( diff --git a/src/main.rs b/src/main.rs index f7f47bc..4205b2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ async fn main() { tracing_subscriber::fmt::init(); dotenv::dotenv().expect("Failed to load .env file."); - let _ = PROCESS_UPTIME.lock().unwrap().clone(); + let _ = *PROCESS_UPTIME.lock().unwrap(); let token = std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!"); @@ -81,7 +81,7 @@ async fn main() { let options = poise::FrameworkOptions { commands, prefix_options: poise::PrefixFrameworkOptions { - prefix: Some(prefix.to_string().into()), + prefix: Some(prefix.to_string()), edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan( Duration::from_secs(3600), ))),