26 lines
817 B
Rust
26 lines
817 B
Rust
use poise::CreateReply;
|
|
use serenity::all::{Colour, CreateEmbed};
|
|
use tenorv2::tenor_builder::Tenor;
|
|
|
|
use crate::{types::Context, utils::gifs::get_random_tenor_gif};
|
|
|
|
/// Sends embed with random tenor gif from searched query
|
|
/// title and desc are used in the embed
|
|
pub(super) async fn send_with_embed(ctx: Context<'_>, query: &str, title: &str, desc: &str) -> anyhow::Result<()> {
|
|
let tenor_response = Tenor::new()?
|
|
.random(true)
|
|
.search(query).await?;
|
|
|
|
const LIMIT: u8 = 20;
|
|
let url = get_random_tenor_gif(tenor_response, LIMIT).await?;
|
|
|
|
let embed = CreateEmbed::new()
|
|
.color(Colour::new(rand::random::<u32>() % 0xFFFFFF))
|
|
.title(title)
|
|
.description(desc)
|
|
.image(url.as_str());
|
|
|
|
ctx.send(CreateReply::default().embed(embed)).await?;
|
|
|
|
Ok(())
|
|
}
|