diff --git a/Cargo.lock b/Cargo.lock index 39abc2d..39c63c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2215,7 +2215,7 @@ dependencies = [ [[package]] name = "soundfx-rs" -version = "1.5.11" +version = "1.5.12" dependencies = [ "axum", "dashmap", diff --git a/Cargo.toml b/Cargo.toml index 168dde3..1f67942 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "soundfx-rs" description = "Discord bot for custom sound effects and soundboards" license = "AGPL-3.0-only" -version = "1.5.11" +version = "1.5.12" authors = ["jellywx "] edition = "2018" diff --git a/src/cmds/play.rs b/src/cmds/play.rs index e441fc9..0555917 100644 --- a/src/cmds/play.rs +++ b/src/cmds/play.rs @@ -78,9 +78,15 @@ pub async fn play_random( join_channel(ctx.serenity_context(), guild.clone(), channel).await; let sounds = ctx.data().guild_sounds(guild.id, None).await?; + if sounds.len() == 0 { + ctx.say("No sounds in this server!").await?; + return Ok(()); + } let ts = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + println!("{}", ts.subsec_micros()); + // This is far cheaper and easier than using an RNG. No reason to use a full RNG here // anyway. match sounds.get(ts.subsec_micros() as usize % sounds.len()) { @@ -97,6 +103,9 @@ pub async fn play_random( ) .await .unwrap(); + + ctx.say(format!("Playing {} (ID {})", sound.name, sound.id)) + .await?; } None => { diff --git a/src/main.rs b/src/main.rs index cda9923..e7cbb29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,6 @@ type Database = MySql; pub struct Data { database: Pool, - http: reqwest::Client, guild_data_cache: DashMap>>, join_sound_cache: DashMap, Option>>, } @@ -159,7 +158,6 @@ async fn main() -> Result<(), Box> { .unwrap(); Ok(Data { - http: reqwest::Client::new(), database, guild_data_cache: Default::default(), join_sound_cache: Default::default(),