moover_rust/src/commands/user_interactions/interaction.rs

27 lines
817 B
Rust
Raw Normal View History

2025-01-31 22:24:33 +00:00
use poise::CreateReply;
use serenity::all::{Colour, CreateEmbed};
2024-10-06 14:53:12 +00:00
use tenorv2::tenor_builder::Tenor;
use crate::{types::Context, utils::gifs::get_random_tenor_gif};
2024-10-06 14:53:12 +00:00
/// Sends embed with random tenor gif from searched query
/// title and desc are used in the embed
2024-10-06 14:53:12 +00:00
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());
2025-01-31 22:24:33 +00:00
ctx.send(CreateReply::default().embed(embed)).await?;
2024-10-06 14:53:12 +00:00
Ok(())
}