use crate::botv2::init::{Context,Error}; use poise::{serenity_prelude::{CreateEmbed, CreateEmbedFooter, CreateMessage}, CreateReply}; use tracing::instrument; /// Enable/Disable auto answer available meme keywords #[instrument(skip(ctx),level="info")] #[poise::command( slash_command, prefix_command, category = "meme" )] pub async fn enable(ctx: Context<'_>) -> Result<(), Error> { tracing::info!(channel = ctx.channel_id().get(), guild = ?ctx.guild_id().unwrap().get(),"Enable command called"); let config_img = ctx.data().config_img.clone(); let list_value: Vec<(String, String, bool)> = config_img .keyword .iter() .map(|x| (x.value.clone().join(", "), String::new(), true)) .collect(); if list_value.is_empty() { let builder = CreateMessage::new().content("No meme keyword found"); if let Err(why) = ctx.channel_id().send_message(ctx.http(), builder).await { tracing::error!("Error sending message: {:?}", why); } return Ok(()); } let embed_vec = list_value.chunks(25).map(|chunks| { let footer = CreateEmbedFooter::new("WeeboBot"); CreateEmbed::new() .title("Meme List") .fields(chunks.to_vec()) .footer(footer) }); let mut reply = CreateReply::default(); reply.embeds = embed_vec.collect(); if let Err(why) = ctx.send(reply).await { tracing::error!("Error sending message: {:?}", why); } Ok(()) } // https://github.com/serenity-rs/poise/blob/current/examples/fluent_localization/main.rs