9 lines
No EOL
378 B
Rust
9 lines
No EOL
378 B
Rust
use tenorv2::{tenor, tenor_types::{MediaFilter, TenorError}, JsonValue};
|
|
|
|
pub async fn get_random_tenor_gif(tenor_response: JsonValue, limit: u8) -> Result<String, TenorError> {
|
|
let index = rand::random::<usize>() % limit as usize;
|
|
match tenor::get_gif_url(MediaFilter::gif, tenor_response) {
|
|
Ok(urls) => Ok(urls[index].clone()),
|
|
Err(e) => Err(e)
|
|
}
|
|
} |