Balanced lil fren and added command to give medicine

+ clippy + fmt
This commit is contained in:
2023-07-09 10:08:51 -06:00
parent e9c10bc34f
commit d25a907ae6
2 changed files with 47 additions and 9 deletions
+39 -2
View File
@@ -11,7 +11,7 @@ use serenity::model::misc::EmojiIdentifier;
use serenity::utils::MessageBuilder;
#[group]
#[commands(adopt, checkup, feed, give_water, play)]
#[commands(adopt, checkup, feed, give_water, play, give_medicine)]
pub struct Buddy;
#[command]
@@ -186,7 +186,7 @@ async fn play(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
if let Some(mut lil_fren) = lil_fren {
if lil_fren.is_alive() == AliveState::Alive {
lil_fren.entertainment =
(lil_fren.entertainment + thread_rng().gen_range(-0.10..1.0)).clamp(-1.0, 1.0);
(lil_fren.entertainment + thread_rng().gen_range(0.10..1.0)).clamp(-1.0, 1.0);
let guild = msg.guild_id.unwrap();
let lil_fren_emoji = guild.emoji(&ctx.http, lil_fren.emoji).await?;
@@ -206,3 +206,40 @@ async fn play(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
Ok(())
}
#[command]
#[description("Help heal buddy")]
async fn give_medicine(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let mut data = ctx.data.write().await;
let global_data = data.get_mut::<GlobalData>().unwrap();
let lil_fren = LilFren::get_lil_fren(&global_data.db)?;
if let Some(mut lil_fren) = lil_fren {
if lil_fren.is_alive() == AliveState::Alive {
let guild = msg.guild_id.unwrap();
let reply = if lil_fren.state == LilFrenState::Sick {
lil_fren.state = LilFrenState::Standing;
"Little buddy feels better now!"
} else {
"Little buddy is now addicted to cough drops, I hope you are happy"
};
let lil_fren_emoji = guild.emoji(&ctx.http, lil_fren.emoji).await?;
global_data.db.insert(lil_fren)?;
msg.reply(&ctx.http, reply).await?;
msg.reply(&ctx.http, lil_fren::draw_feed(&lil_fren_emoji, ":pill:"))
.await?;
} else {
msg.reply(&ctx.http, "You may want to check on your buddy...")
.await?;
}
} else {
msg.reply(&ctx.http, "Sorry no little buddy found!").await?;
}
Ok(())
}