From 130be477d0cf0edd20068e7261ea9b1a8b5e29a4 Mon Sep 17 00:00:00 2001 From: "oupson1er@gmail.com" Date: Wed, 17 Mar 2021 23:46:59 +0100 Subject: [PATCH] Fix conflicts --- .gitignore | 3 +- .vs/settings.json | 7 ---- Cargo.toml | 7 +--- src/commands/roulette.rs | 74 +--------------------------------------- src/main.rs | 25 +++++++++----- 5 files changed, 19 insertions(+), 97 deletions(-) delete mode 100644 .vs/settings.json diff --git a/.gitignore b/.gitignore index 7cf5fc8..86f2cd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /target -/.vs/* -!/.vs/settings.json +/.vscode /logging/ Cargo.lock Conf.toml diff --git a/.vs/settings.json b/.vs/settings.json deleted file mode 100644 index b7fe30b..0000000 --- a/.vs/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rust-analyzer.cargo.features": [ - "music" - ], - "rust-analyzer.cargo.loadOutDirsFromCheck": true, - "rust-analyzer.procMacro.enable": true -} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 7c7df54..00ff139 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,11 +22,6 @@ futures = "0.3" chrono = "0.4" serde_json = "1.0" log = "0.4" -<<<<<<< HEAD -log4rs = "0.13" -ctrlc = "3.1" -songbird = { version = "0.1.0", features = ["driver"], optional = true } -======= log4rs = "1.0" ctrlc = "3.1" ->>>>>>> 5794295d3a1a5477a1c417879da0f0c284160c7f +songbird = { version = "0.1.0", features = ["driver"], optional = true } \ No newline at end of file diff --git a/src/commands/roulette.rs b/src/commands/roulette.rs index 9aa635b..c31ccea 100644 --- a/src/commands/roulette.rs +++ b/src/commands/roulette.rs @@ -30,7 +30,6 @@ async fn shot(ctx: &Context, msg: &Message, args: Args) -> CommandResult { } else { api::send_reply(&ctx, &msg, format!("Click ! Reloading")).await?; } -<<<<<<< HEAD } else { api::send_reply( ctx, @@ -38,65 +37,6 @@ async fn shot(ctx: &Context, msg: &Message, args: Args) -> CommandResult { format!("Error : {} is not a valid argument", args.message()), ) .await?; -======= - } else if let Err(e) = api::send_reply( - ctx, - msg, - format!("Error : {} is not a valid argument", args.message()), - ) - .await - { - error!("Error : {:?}", e); - } - Ok(()) -} - -#[command] -#[description = "Reload"] -#[bucket = "roulette"] -async fn reload(ctx: &Context, msg: &Message) -> CommandResult { - if let Err(e) = _reload(ctx, msg).await { - error!("{}", e); - } - Ok(()) -} - -async fn _reload(ctx: &Context, msg: &Message) -> commands::Result<()> { - let mut data = ctx.data.write().await; - 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))); - msg.react(ctx, ReactionType::Unicode(String::from("✅"))) - .await?; - Ok(()) -} - -#[command] -#[description = "If you use that, you are a coward"] -async fn check(ctx: &Context, msg: &Message) -> CommandResult { - let mut data = ctx.data.write().await; - let bullets_map = data - .get_mut::() - .expect("Expected CommandCounter in TypeMap."); - let bullets = bullets_map - .entry(msg.author.id.0) - .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(()) -} - -fn bullet_to_str<'m>(nbr: u8) -> &'m str { - match nbr { - 1 => "first", - 2 => "second", - 3 => "third", - 4 => "fourth", - 5 => "fifth", - 6 => "sixth", - _ => unimplemented!(), ->>>>>>> 5794295d3a1a5477a1c417879da0f0c284160c7f } Ok(()) } @@ -120,8 +60,7 @@ async fn kick(ctx: &Context, msg: &Message) -> CommandResult { ) .await?; } else { -<<<<<<< HEAD - if rand::thread_rng().gen_range(0, 6) == 0 { + if rand::thread_rng().gen_range(0..6) == 0 { api::send_reply(ctx, &msg, "💥").await?; msg.author @@ -129,17 +68,6 @@ async fn kick(ctx: &Context, msg: &Message) -> CommandResult { .await? .send_message(&ctx.http, |m| m.content("<:cheh:780736245675982909>")) .await?; -======= - let bullets_map = data - .get_mut::() - .expect("Expected CommandCounter in TypeMap."); - let bullets = bullets_map - .entry(msg.author.id.0) - .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)); ->>>>>>> 5794295d3a1a5477a1c417879da0f0c284160c7f guild_id .member(&ctx.http, &msg.author) diff --git a/src/main.rs b/src/main.rs index 6ae8e38..181dfe8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,10 +27,12 @@ use std::{ time::Duration, }; use tokio::{fs::File, io::AsyncWriteExt}; + +#[cfg(feature = "music")] use songbird::SerenityInit; #[cfg(feature = "music")] -use crate::commands::music::{MUSIC_GROUP}; +use crate::commands::music::MUSIC_GROUP; mod api; mod commands; @@ -131,10 +133,13 @@ async fn main() -> IoResult<()> { let mut client = Client::builder(&token) .event_handler(Messages {}) - .framework(framework) - .register_songbird() - .await - .unwrap(); + .framework(framework); + + #[cfg(feature = "music")] + { + client = client.register_songbird(); + }; + let mut client = client.await.unwrap(); { let mut data = client.data.write().await; @@ -194,7 +199,7 @@ impl EventHandler for Messages { .await; tokio::time::sleep(delay).await; } - } + } async fn message(&self, _ctx: Context, new_message: Message) { if unsafe { LOG_ATTACHMENTS } && !new_message.attachments.is_empty() { @@ -215,14 +220,17 @@ impl EventHandler for Messages { ctx: Context, channel_id: ChannelId, deleted_message_id: MessageId, - _guild_id: Option + _guild_id: Option, ) { let message = ctx .cache() .unwrap() .message(channel_id, deleted_message_id) .await; - log::debug!("Deletted message : {:?}", message.as_ref().map(|m| &m.content)); + log::debug!( + "Deletted message : {:?}", + message.as_ref().map(|m| &m.content) + ); if let Some(message) = message { if let Some(guild_id) = message.guild_id { @@ -230,7 +238,6 @@ impl EventHandler for Messages { let mut data = ctx.data.write().await; let guilds_options = data.get_mut::().unwrap(); - let entry = guilds_options .entry(guild_id) .or_insert_with(|| GuildOptions::default().set_guild_id(guild_id));