summaryrefslogtreecommitdiff
path: root/src/commands/general/random.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/general/random.rs')
-rw-r--r--src/commands/general/random.rs44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/commands/general/random.rs b/src/commands/general/random.rs
index 094123b..053e4bb 100644
--- a/src/commands/general/random.rs
+++ b/src/commands/general/random.rs
@@ -1,22 +1,14 @@
-use crate::{client::Context, consts, http, utils};
+use crate::{client::Context, http, utils};
-use eyre::Result;
+use anyhow::Result;
+use rand::Rng;
-#[poise::command(slash_command, subcommands("lore", "teawie", "shiggy"))]
+#[poise::command(slash_command, subcommands("teawie", "shiggy", "uwu"))]
#[allow(clippy::unused_async)]
pub async fn random(_: Context<'_>) -> Result<()> {
Ok(())
}
-/// Get a random piece of teawie lore!
-#[poise::command(prefix_command, slash_command)]
-pub async fn lore(ctx: Context<'_>) -> Result<()> {
- let resp = utils::random_choice(consts::LORE)?;
- ctx.say(resp).await?;
-
- Ok(())
-}
-
/// Get a random teawie
#[poise::command(prefix_command, slash_command)]
pub async fn teawie(ctx: Context<'_>) -> Result<()> {
@@ -34,3 +26,31 @@ pub async fn shiggy(ctx: Context<'_>) -> Result<()> {
Ok(())
}
+
+/// Some uwu
+#[poise::command(prefix_command, slash_command)]
+pub async fn uwu(
+ ctx: Context<'_>,
+ #[description = "The amount of uwurandom to generate"]
+ #[min = 1]
+ #[max = 100]
+ length: Option<u16>,
+) -> Result<()> {
+ let length = length.unwrap_or(rand::thread_rng().gen_range(1..50));
+
+ let mut result = String::with_capacity(length as usize);
+ // ThreadRng is not Send(obviously), and rustc is slightly too paranoid about rng spilling to await point
+ // So calm it by constraining it to a block
+ {
+ let mut rng = rand::thread_rng();
+ let mut state_machine = uwurandom_rs::StateMachine::new(&mut rng);
+ for _ in 0..length {
+ let generated;
+ (state_machine, generated) = state_machine.generate(&mut rng);
+ result.push(generated);
+ }
+ }
+ ctx.say(result).await?;
+
+ Ok(())
+}