cargo fmt

This commit is contained in:
shibedrill 2024-04-16 22:28:53 -04:00
parent 8b7a7a5631
commit 54f319cb95
3 changed files with 28 additions and 49 deletions

View File

@ -1,6 +1,5 @@
use rand::Rng;
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rand::Rng;
use crate::Context; use crate::Context;
use crate::Error; use crate::Error;
@ -8,48 +7,17 @@ use crate::Error;
/// MAKE HER BLEAT /// MAKE HER BLEAT
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn bleat(ctx: Context<'_>) -> Result<(), Error> { pub async fn bleat(ctx: Context<'_>) -> Result<(), Error> {
let sounds: Vec<&str> = [ let sounds: Vec<&str> = [
"rah", "rah", "grr", "bah", "bleat", "yippee", "woohoo", "huh", "wha", "buh", "whuh", "oh",
"grr", "yeag", "yeab", "yeas", "mweee", "mweh", "bwah",
"bah", ]
"bleat", .to_vec();
"yippee",
"woohoo",
"huh",
"wha",
"buh",
"whuh",
"oh",
"yeag",
"yeab",
"yeas",
"mweee",
"mweh",
"bwah",
].to_vec();
let faces: Vec<&str> = vec![
"xp",
"x3",
":3",
":3c",
";3",
";3c",
"=p",
].to_vec();
let exclamation: Vec<&str> = vec![ let faces: Vec<&str> = vec!["xp", "x3", ":3", ":3c", ";3", ";3c", "=p"].to_vec();
"!",
"1", let exclamation: Vec<&str> = vec!["!", "1", "?", "-", ",", "."].to_vec();
"?",
"-",
",",
".",
].to_vec();
fn modify_sound(input: &str) -> String { fn modify_sound(input: &str) -> String {
// Create an RNG // Create an RNG
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
@ -73,26 +41,37 @@ pub async fn bleat(ctx: Context<'_>) -> Result<(), Error> {
let count = rand::thread_rng().gen_range(1..3); let count = rand::thread_rng().gen_range(1..3);
let mut new_sound: String = String::new(); let mut new_sound: String = String::new();
for _i in 0..count { for _i in 0..count {
new_sound.push_str(&modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())); new_sound.push_str(&modify_sound(
sounds.choose(&mut rand::thread_rng()).unwrap(),
));
new_sound.push(' '); new_sound.push(' ');
} }
new_sound new_sound
} }
11 => { 11 => {
format!("am so {}ing awesome", modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())) format!(
"am so {}ing awesome",
modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())
)
} }
12 => { 12 => {
format!("feel so {} like a {} machine", modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap()), modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())) format!(
"feel so {} like a {} machine",
modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap()),
modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())
)
} }
13 => { 13 => {
format!("do it {}", modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())) format!(
"do it {}",
modify_sound(sounds.choose(&mut rand::thread_rng()).unwrap())
)
} }
_ => unreachable!(), _ => unreachable!(),
}; };
ctx.say(sound) // This unwrap will never return None. We promise this slice will always be non empty. ctx.say(sound) // This unwrap will never return None. We promise this slice will always be non empty.
.await?; .await?;
info!("Executed command `bleat` successfully"); info!("Executed command `bleat` successfully");
Ok(()) Ok(())
} }

View File

@ -1,2 +1,2 @@
pub mod fun;
pub mod util; pub mod util;
pub mod fun;

View File

@ -7,7 +7,7 @@ extern crate pretty_env_logger;
extern crate log; extern crate log;
mod command; mod command;
use crate::command::{util::*, fun::*,}; use crate::command::{fun::*, util::*};
struct Data {} // User data, which is stored and accessible in all command invocations struct Data {} // User data, which is stored and accessible in all command invocations
type Error = Box<dyn std::error::Error + Send + Sync>; type Error = Box<dyn std::error::Error + Send + Sync>;