Skip to content

Commit

Permalink
Replace manual emoji formatting with enum
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinegb committed Apr 12, 2024
1 parent e22de20 commit e78e6b4
Showing 1 changed file with 165 additions and 46 deletions.
211 changes: 165 additions & 46 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

mod boredom;

use std::sync::{atomic::AtomicBool, Arc};
use std::{
fmt,
sync::{atomic::AtomicBool, Arc},
};

use anyhow::Context as _;
use boredom::{check_for_boredom, check_for_boredom_acknowledgment, BoredomTracker};
Expand All @@ -33,26 +36,103 @@ struct UserData {} // User data, which is stored and accessible in all command i
type Error = Box<dyn std::error::Error + Send + Sync>;
type Context<'a> = poise::Context<'a, UserData, Error>;

#[allow(dead_code)]
enum FloofEmoji {
AFloofLoad,
Floof,
FloofAngry,
FloofBlep,
FloofCat,
FloofCool,
FloofCry,
FloofDrool,
FloofHappy,
FloofHeart,
FloofInnocent,
FloofLoad,
FloofLol,
FloofLurk,
FloofMischief,
FloofMug,
FloofNervous,
FloofNom,
FloofOwo,
FloofPat,
FloofPeek,
FloofPlead,
FloofSad,
FloofScared,
FloofSmug,
FloofTeehee,
FloofTired,
FloofWhat,
FloofWoozy,
}

impl fmt::Display for FloofEmoji {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FloofEmoji::AFloofLoad => write!(f, "<a:afloofLoad:1227015489792905360>"),
FloofEmoji::Floof => write!(f, "<:floof:1226944669448147044>"),
FloofEmoji::FloofAngry => write!(f, "<:floofAngry:1226944671423660133>"),
FloofEmoji::FloofBlep => write!(f, "<:floofBlep:1226944673281609788>"),
FloofEmoji::FloofCat => write!(f, "<:floofCat:1226944674988687491>"),
FloofEmoji::FloofCool => write!(f, "<:floofCool:1226944677387698226>"),
FloofEmoji::FloofCry => write!(f, "<:floofCry:1226944679833112598>"),
FloofEmoji::FloofDrool => write!(f, "<:floofDrool:1226944681477406801>"),
FloofEmoji::FloofHappy => write!(f, "<:floofHappy:1226944682815258755>"),
FloofEmoji::FloofHeart => write!(f, "<:floofHeart:1226944685210341467>"),
FloofEmoji::FloofInnocent => write!(f, "<:floofInnocent:1226944687412215828>"),
FloofEmoji::FloofLoad => write!(f, "<:floofLoad:1226944689546989710>"),
FloofEmoji::FloofLol => write!(f, "<:floofLol:1226944692541980692>"),
FloofEmoji::FloofLurk => write!(f, "<:floofLurk:1226944909446090922>"),
FloofEmoji::FloofMischief => write!(f, "<:floofMischief:1226944697579077692>"),
FloofEmoji::FloofMug => write!(f, "<:floofMug:1226944701345828904>"),
FloofEmoji::FloofNervous => write!(f, "<:floofNervous:1226944704541622394>"),
FloofEmoji::FloofNom => write!(f, "<:floofNom:1226944708366831637>"),
FloofEmoji::FloofOwo => write!(f, "<:floofOwO:1226944711768412280>"),
FloofEmoji::FloofPat => write!(f, "<:floofPat:1226944714234794044>"),
FloofEmoji::FloofPeek => write!(f, "<:floofPeek:1226944911857815594>"),
FloofEmoji::FloofPlead => write!(f, "<:floofPlead:1226944718735151266>"),
FloofEmoji::FloofSad => write!(f, "<:floofSad:1226944722908483665>"),
FloofEmoji::FloofScared => write!(f, "<:floofScared:1226944726096285777>"),
FloofEmoji::FloofSmug => write!(f, "<:floofSmug:1226944728734629970>"),
FloofEmoji::FloofTeehee => write!(f, "<:floofTeehee:1226944732169502761>"),
FloofEmoji::FloofTired => write!(f, "<:floofTired:1226944734640078878>"),
FloofEmoji::FloofWhat => write!(f, "<:floofWhat:1226944914315804683>"),
FloofEmoji::FloofWoozy => write!(f, "<:floofWoozy:1226944739593424957>"),
}
}
}

/// ```
/// rp_command!(
/// name: ident,
/// context_menu_name: literal,
/// description: literal,
/// user_description: literal,
/// [ message..: literal ],
/// bot_message: literal,
/// self_message: literal,
/// [ (message: literal, emoji: expr).. ],
/// (bot_message: literal, emoji: expr),
/// (self_message: literal, emoji: expr),
/// );
/// ```
///
/// Variables usable in messages:
///
/// - `a`: mention of the user that invoked the command
/// - `b`: mention of the user the command is being used on
/// - `e`: emoji for the message
///
/// Example: `"{a} did something to {b} {e}"`
macro_rules! rp_command {
(
$name:ident,
$context_menu_name:literal,
$description:literal,
$user_description:literal,
[$($message:literal),+$(,)?],
$bot_message:literal,
$self_message:literal$(,)?
[$(($message:literal, $emoji:expr$(,)?)),+$(,)?],
($bot_message:literal, $bot_emoji:expr$(,)?),
($self_message:literal, $self_emoji:expr$(,)?)$(,)?
) => {
#[doc = $description]
#[poise::command(slash_command, context_menu_command = $context_menu_name)]
Expand All @@ -65,13 +145,22 @@ macro_rules! rp_command {
data.insert::<BoredomTracker>(Arc::new(AtomicBool::new(false)));

let author_mention = ctx.author().mention();
let bot_message = format!($bot_message, a = author_mention);
let self_message = format!($self_message, a = author_mention);
let bot_message = format!(
$bot_message,
a = author_mention,
e = $bot_emoji,
);
let self_message = format!(
$self_message,
a = author_mention,
e = $self_emoji,
);
let messages = [
$(format!(
$message,
a = author_mention,
b = user.mention(),
e = $emoji,
)),+
];
let picked_message;
Expand Down Expand Up @@ -102,14 +191,23 @@ rp_command!(
"Boops a being :3c",
"Your victim >:3",
[
"{a} booped {b}!!! <:floofOwO:1226944711768412280>",
"{b} just got booped by {a}?? <a:afloofLoad:1227015489792905360>",
"Lmao I just saw {a} boop {b} <:floofLol:1226944692541980692>",
"Dear {b},\n\nGet booped, nerd. <:floofSmug:1226944728734629970>\n\nSincerely, {a}",
"{a} booped {b}, I think they're trying to pick a fight <:floofNervous:1226944704541622394>",
("{a} booped {b}!!! {e}", FloofEmoji::FloofOwo),
("{b} just got booped by {a}?? {e}", FloofEmoji::AFloofLoad),
("Lmao I just saw {a} boop {b} {e}", FloofEmoji::FloofLol),
(
"Dear {b},\n\nGet booped, nerd. {e}\n\nSincerely, {a}",
FloofEmoji::FloofSmug
),
(
"{a} booped {b}, I think they're trying to pick a fight {e}",
FloofEmoji::FloofNervous
),
],
"I have been booped by {a} <:floofOwO:1226944711768412280>",
"{a} just booped themselves... that's a little sad, won't someone else boop them? <:floofSad:1226944722908483665>",
("I have been booped by {a} {e}", FloofEmoji::FloofOwo),
(
"{a} just booped themselves... that's a little sad, won't someone else boop them? {e}",
FloofEmoji::FloofSad,
),
);

rp_command!(
Expand All @@ -118,13 +216,25 @@ rp_command!(
"Embrace the bobin within us all and gnaw on one's bones",
"The subject of today's gnawing",
[
"{a} is gnawing on {b}'s bones <:floofNom:1226944708366831637>",
"{a} craves the bones of {b} <:floofNom:1226944708366831637>",
"{a} hungers for the bones of a {b} <:floofNom:1226944708366831637>",
"Hey uh, {b}, did you know there's a {a} gnawing on your bones? <:floofLurk:1226944909446090922>",
("{a} is gnawing on {b}'s bones {e}", FloofEmoji::FloofNom),
("{a} craves the bones of {b} {e}", FloofEmoji::FloofNom),
(
"{a} hungers for the bones of a {b} {e}",
FloofEmoji::FloofNom,
),
(
"Hey uh, {b}, did you know there's a {a} gnawing on your bones? {e}",
FloofEmoji::FloofLurk,
),
],
"GRAAAHH {a} STOP GNAWING MY BONES GET OFF HELP <:floofScared:1226944726096285777>",
"{a}'s gnawing on... their own bones? Are they good...? <a:afloofLoad:1227015489792905360>",
(
"GRAAAHH {a} STOP GNAWING MY BONES GET OFF HELP {e}",
FloofEmoji::FloofScared,
),
(
"{a}'s gnawing on... their own bones? Are they good...? {e}",
FloofEmoji::AFloofLoad,
),
);

rp_command!(
Expand All @@ -133,13 +243,22 @@ rp_command!(
"Express a wide range of emotions via- your teeth in somebody's skin",
"The skin-haver in question",
[
"D- did {a} just bite {b}?? <:floofOwO:1226944711768412280>",
"Awww, {a} gave {b} a love bite... I think- actually, it's hard to say <:floofTired:1226944734640078878>",
"The intrusive thoughts won and now {a}'s biting {b} <:floofMischief:1226944697579077692>",
"\\*CHOMP\\*\n{a} bit {b} <:floofNom:1226944708366831637>",
("D- did {a} just bite {b}?? {e}", FloofEmoji::FloofOwo),
(
"Awww, {a} gave {b} a love bite... I think- actually, it's hard to say {e}",
FloofEmoji::FloofTired,
),
(
"The intrusive thoughts won and now {a}'s biting {b} {e}",
FloofEmoji::FloofMischief,
),
("\\*CHOMP\\*\n{a} bit {b} {e}", FloofEmoji::FloofNom),
],
"Help please {a}'s biting me <:floofOwO:1226944711768412280>",
"{a} bit themselves... why'd they do that? <a:afloofLoad:1227015489792905360>",
("Help please {a}'s biting me {e}", FloofEmoji::FloofOwo),
(
"{a} bit themselves... why'd they do that? {e}",
FloofEmoji::AFloofLoad,
),
);

rp_command!(
Expand All @@ -148,17 +267,17 @@ rp_command!(
"You know what you are",
"Get their attention",
[
"Uhh, {a} just meowed at {b} <:floofWhat:1226944914315804683>",
"{a} is a furry and they want {b} to know it <:floofMischief:1226944697579077692>",
"{a} is so silly, they think {b} can understand their meowing <:floofLol:1226944692541980692>",
"{b}, be afraid... {a} is meowing at you <:floofPeek:1226944911857815594>",
"{b}, {a} is meowing at you, won't you give them what they want? <:floofPlead:1226944718735151266>",
"{b}, I have a message for you: \"meow meow meow meow meow meow meow meow\"\n{a} gave it to me <:floofHappy:1226944682815258755>",
"{a} just *nya*-ed all over the place- {b}, clean this up! <:floofWhat:1226944914315804683>",
"{b}... sire... I have a message for you, from {a}... \\*ahem\\*... \"meow meow meow, meow meow, meow meow meow meow meow, meow!\"\nI'm just the messenger please don't hurt me <:floofNervous:1226944704541622394>",
("Uhh, {a} just meowed at {b} {e}", FloofEmoji::FloofWhat),
("{a} is a furry and they want {b} to know it {e}", FloofEmoji::FloofMischief),
("{a} is so silly, they think {b} can understand their meowing {e}", FloofEmoji::FloofLol),
("{b}, be afraid... {a} is meowing at you {e}", FloofEmoji::FloofPeek),
("{b}, {a} is meowing at you, won't you give them what they want? {e}", FloofEmoji::FloofPlead),
("{b}, I have a message for you: \"meow meow meow meow meow meow meow meow\"\n{a} gave it to me {e}", FloofEmoji::FloofHappy),
("{a} just *nya*-ed all over the place- {b}, clean this up! {e}", FloofEmoji::FloofWhat),
("{b}... sire... I have a message for you, from {a}... \\*ahem\\*... \"meow meow meow, meow meow, meow meow meow meow meow, meow!\"\nI'm just the messenger please don't hurt me {e}", FloofEmoji::FloofNervous),
],
"Hm? What's that {a}? Oh I see... mhm... okay, okay, I understand <:floofCat:1226944674988687491>",
"{a} is meowing at themselves lol, schizophrenic cat <:floofCat:1226944674988687491>",
("Hm? What's that {a}? Oh I see... mhm... okay, okay, I understand {e}", FloofEmoji::FloofCat),
("{a} is meowing at themselves lol, schizophrenic cat {e}", FloofEmoji::FloofCat),
);

rp_command!(
Expand All @@ -167,15 +286,15 @@ rp_command!(
"MURRRRRDEERRRRRRRRRRR",
"KILL THEM KILL THEM KILL THEM >:D",
[
"{a} crept up behind {b} and murdered them!!! <:floofOwO:1226944711768412280>",
"{a} just pulled out a bazooka and blew {b} up!?!? <:floofOwO:1226944711768412280>",
"{a} stared directly into {b}'s eyes and shouted \"POMEGRANATE\", triggering the cognitohazard previously planted in {b}'s brain, killing them instantly <:floofNervous:1226944704541622394>",
"{a} just went \"BOO\", giving {b} a fatal heart attack <:floofOwO:1226944711768412280>",
"{a} just went \"OOGA BOOGA\", giving {b} a fatal heart attack <:floofOwO:1226944711768412280>",
"{a} killed {b} when the lights went out so no one would know it was them... <:floofSmug:1226944728734629970>",
("{a} crept up behind {b} and murdered them!!! {e}", FloofEmoji::FloofOwo),
("{a} just pulled out a bazooka and blew {b} up!?!? {e}", FloofEmoji::FloofOwo),
("{a} stared directly into {b}'s eyes and shouted \"POMEGRANATE\", triggering the cognitohazard previously planted in {b}'s brain, killing them instantly {e}", FloofEmoji::FloofNervous),
("{a} just went \"BOO\", giving {b} a fatal heart attack {e}", FloofEmoji::FloofOwo),
("{a} just went \"OOGA BOOGA\", giving {b} a fatal heart attack {e}", FloofEmoji::FloofOwo),
("{a} killed {b} when the lights went out so no one would know it was them... {e}", FloofEmoji::FloofSmug),
],
"GAH {a} HAS A KNIFE AND IS RUNNING AT ME WAAAA <:floofScared:1226944726096285777>",
"BAH- {a} JUST K-KILLED THEMSELF??? NOOOOOOOOOO <:floofScared:1226944726096285777>",
("GAH {a} HAS A KNIFE AND IS RUNNING AT ME WAAAA {e}", FloofEmoji::FloofScared),
("BAH- {a} JUST K-KILLED THEMSELF??? NOOOOOOOOOO {e}", FloofEmoji::FloofScared),
);

#[shuttle_runtime::main]
Expand Down

0 comments on commit e78e6b4

Please sign in to comment.