38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
|
use anyhow::anyhow;
|
||
|
use serenity::all::{Colour, CreateEmbed, CreateMessage};
|
||
|
use tenorv2::tenor_builder::Tenor;
|
||
|
|
||
|
use crate::{types::Context, util::{gifs::get_random_tenor_gif, utilities}};
|
||
|
|
||
|
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());
|
||
|
|
||
|
if ctx.guild_id().is_none() {
|
||
|
return Err(anyhow!("Guild id not available in context"));
|
||
|
}
|
||
|
|
||
|
utilities::get_system_channel(
|
||
|
ctx.guild_id().unwrap(), ctx.http()
|
||
|
).await?
|
||
|
.send_message(
|
||
|
ctx.http(),
|
||
|
CreateMessage::new().add_embed(embed)
|
||
|
).await?;
|
||
|
|
||
|
Ok(())
|
||
|
}
|
||
|
|
||
|
pub(super) async fn send(ctx: Context<'_>, msg: &str) -> anyhow::Result<()> {
|
||
|
Ok(())
|
||
|
}
|