diff --git a/Cargo.toml b/Cargo.toml index 700d5f5..0ca4007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,17 +10,17 @@ edition = "2018" music = ["serenity/voice"] [dependencies] -serenity = "0.9" +serenity = "0.10" toml = "0.5" serde = { version = "1.0", features = ["derive"] } -reqwest = "0.10" -rand = "0.7" +reqwest = "0.11" +rand = "0.8" lazy_static = "1.4" async-trait = "0.1" -tokio = { version = "0.2", features = ["full"] } +tokio = { version = "1.0", features = ["full"] } futures = "0.3" chrono = "0.4" serde_json = "1.0" log = "0.4" -log4rs = "0.13" +log4rs = "1.0" ctrlc = "3.1" \ No newline at end of file diff --git a/src/commands/roulette.rs b/src/commands/roulette.rs index b91b473..110c286 100644 --- a/src/commands/roulette.rs +++ b/src/commands/roulette.rs @@ -25,7 +25,7 @@ struct Roulette; async fn shot(ctx: &Context, msg: &Message, args: Args) -> CommandResult { let _message = args.message().trim_end(); if _message == "shot" || _message == "" { - if rand::thread_rng().gen_range(0, 6) == 0 { + if rand::thread_rng().gen_range(0..6) == 0 { api::send_reply(ctx, &msg, "💥").await?; } else { api::send_reply(&ctx, &msg, format!("Click ! Reloading")).await?; @@ -57,7 +57,7 @@ async fn _reload(ctx: &Context, msg: &Message) -> commands::Result<()> { let bullets_map = data .get_mut::() .expect("Expected CommandCounter in TypeMap."); - bullets_map.insert(msg.author.id.0, (5, rand::thread_rng().gen_range(0, 6))); + bullets_map.insert(msg.author.id.0, (5, rand::thread_rng().gen_range(0..6))); msg.react(ctx, ReactionType::Unicode(String::from("✅"))) .await?; Ok(()) @@ -72,7 +72,7 @@ async fn check(ctx: &Context, msg: &Message) -> CommandResult { .expect("Expected CommandCounter in TypeMap."); let bullets = bullets_map .entry(msg.author.id.0) - .or_insert((5, rand::thread_rng().gen_range(0, 6))); + .or_insert((5, rand::thread_rng().gen_range(0..6))); msg.channel_id.say(ctx, format!("Because you are a little shit, you open your barrel and you see that the bullet was at the {} position", bullet_to_str(bullets.1 + 1))).await?; debug!("Bullets Map : {:?}", bullets_map); Ok(()) @@ -127,10 +127,10 @@ async fn _kick(ctx: &Context, msg: &Message) -> CommandResult { .expect("Expected CommandCounter in TypeMap."); let bullets = bullets_map .entry(msg.author.id.0) - .or_insert((5, rand::thread_rng().gen_range(0, 6))); + .or_insert((5, rand::thread_rng().gen_range(0..6))); if bullets.0 == bullets.1 { api::send_reply(ctx, &msg, "💥").await?; - *bullets = (5, rand::thread_rng().gen_range(0, 6)); + *bullets = (5, rand::thread_rng().gen_range(0..6)); guild_id .member(&ctx.http, &msg.author) diff --git a/src/main.rs b/src/main.rs index 11af12c..05befc2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,45 +171,6 @@ async fn main() -> IoResult<()> { struct Messages {} -impl Messages { - /*async fn _reaction_add( - &self, - ctx: Context, - reaction: Reaction, - ) -> Result<(), Box> { - // TODO - let message: Message = reaction.message(&ctx.http).await?; - if message.is_own(&ctx).await && message.content.starts_with("Do you want to take the gun") - { - debugln!("My own garbage !"); - let user = reaction.user(&ctx.http).await?; - if user == message.mentions[1] { - message.delete(&ctx.http).await?; - if reaction.emoji - == serenity::model::channel::ReactionType::Unicode(String::from("✅")) - { - let mut data = ctx.data.write().await; - let bullets_map = data - .get_mut::() - .expect("Expected CommandCounter in TypeMap."); - if bullets_map.contains_key(&message.mentions[0].id.0) { - let bullet_count = - bullets_map.remove(&message.mentions[0].id.0).unwrap_or(6); - bullets_map.insert(message.mentions[1].id.0, bullet_count); - message.channel_id.say(&ctx, "Done").await?; - } else { - message - .channel_id - .say(&ctx, "Error : Your gun is empty") - .await?; - } - } - } - } - Ok(()) - }*/ -} - #[async_trait] impl EventHandler for Messages { async fn ready(&self, ctx: Context, ready: Ready) { @@ -225,9 +186,9 @@ impl EventHandler for Messages { ctx_clone .set_presence(Some(act), OnlineStatus::Online) .await; - tokio::time::delay_for(delay).await; + tokio::time::sleep(delay).await; } - } + } async fn message(&self, _ctx: Context, new_message: Message) { if unsafe { LOG_ATTACHMENTS } && !new_message.attachments.is_empty() {