Fix conflicts

This commit is contained in:
oupson1er@gmail.com 2021-03-17 23:46:59 +01:00
parent 71acc6f62e
commit 130be477d0
5 changed files with 19 additions and 97 deletions

3
.gitignore vendored
View File

@ -1,6 +1,5 @@
/target
/.vs/*
!/.vs/settings.json
/.vscode
/logging/
Cargo.lock
Conf.toml

View File

@ -1,7 +0,0 @@
{
"rust-analyzer.cargo.features": [
"music"
],
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.procMacro.enable": true
}

View File

@ -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 }

View File

@ -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::<BulletsContainer>()
.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::<BulletsContainer>()
.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::<BulletsContainer>()
.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)

View File

@ -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;
@ -215,14 +220,17 @@ impl EventHandler for Messages {
ctx: Context,
channel_id: ChannelId,
deleted_message_id: MessageId,
_guild_id: Option<GuildId>
_guild_id: Option<GuildId>,
) {
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::<GuildOptionsKey>().unwrap();
let entry = guilds_options
.entry(guild_id)
.or_insert_with(|| GuildOptions::default().set_guild_id(guild_id));