use async_trait::async_trait; use crate::extras::Extras; use crate::framework::interactions::InteractionError; use crate::framework::interactions::components::Button; use crate::framework::interactions::context::InteractionContext; use crate::framework::messages::MessageEditBuilder; use crate::groups::about::embeds::get_all_command_help_embed; use crate::state::State; #[derive(Debug)] pub struct HelpGoBackButton; #[async_trait] impl Button for HelpGoBackButton { fn id(&self) -> Option { Some("help:go-back".into()) } fn label(&self) -> Option { Some("← Go back to commands list".into()) } async fn on_press( &self, ctx: InteractionContext, ) -> Result<(), InteractionError> { ctx .edit_original_message( MessageEditBuilder::new().embed( get_all_command_help_embed(&ctx.prefix, &ctx.rt, &ctx.extras) ) .component(HelpWebsiteLinkButton, 1) .component(HelpSupportLinkButton, 1) .component(HelpDonateLinkButton, 1) .component(CodeOfConductLinkButton, 1) ) .await .inspect_err(|e| log::error!("An error occurred while attempting to edit the original message of an interaction. {e:?}")) .map_err( |_| InteractionError::OriginalMessageEditingFailed )?; Ok(()) } } #[derive(Debug)] pub struct HelpSupportLinkButton; #[async_trait] impl Button for HelpSupportLinkButton { fn label(&self) -> Option { Some("Get help".into()) } fn url(&self) -> Option { Some("https://discord.gg/9daSsrfTmE".into()) } } #[derive(Debug)] pub struct HelpWebsiteLinkButton; #[async_trait] impl Button for HelpWebsiteLinkButton { fn label(&self) -> Option { Some("Website".into()) } fn url(&self) -> Option { Some("https://payphone.lat/".into()) } } #[derive(Debug)] pub struct HelpDonateLinkButton; #[async_trait] impl Button for HelpDonateLinkButton { fn label(&self) -> Option { Some("Donate".into()) } fn url(&self) -> Option { Some("https://ko-fi.com/payphonedev".into()) } } #[derive(Debug)] pub struct CodeOfConductLinkButton; #[async_trait] impl Button for CodeOfConductLinkButton { fn label(&self) -> Option { Some("Code of Conduct".into()) } fn url(&self) -> Option { Some("https://payphone.lat/code-of-conduct".into()) } }