diff options
| author | seth <[email protected]> | 2023-04-07 19:59:19 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2023-04-07 20:00:57 -0400 |
| commit | bb3df7e6ab9de4c52fbe81b589ac5d1add6d281d (patch) | |
| tree | d0642d24fe96e8ea6d98969a20975b611ec11d53 /src/utils.rs | |
| parent | 83f885ee8d762551a6c5d8ea5ab3719cde76464a (diff) | |
add random lore command
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/utils.rs b/src/utils.rs index 4157e3b..bb57521 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,17 +9,30 @@ const CHAR_LIMIT: usize = 2000; const FILES: Dir = include_dir!("src/include"); /* - * chooses a random response out of our options + * chooses a random element from an array */ -pub async fn get_random_response() -> String { +async fn random_choice<const N: usize>(arr: [&str; N]) -> String { let mut rng = rand::thread_rng(); - let resp = RESPONSES + let resp = arr .choose(&mut rng) .expect("couldn't choose random value!"); resp.to_string() } /* + * pub functions to get random elements + * from our consts + */ + +pub async fn get_random_response() -> String { + random_choice(RESPONSES).await +} + +pub async fn get_random_lore() -> String { + random_choice(LORE).await +} + +/* * splits a message into multiple parts so that * it can fit discord's character limit */ |
