103 lines
2.6 KiB
Rust
103 lines
2.6 KiB
Rust
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<State, Extras> for HelpGoBackButton {
|
|
fn id(&self) -> Option<String> {
|
|
Some("help:go-back".into())
|
|
}
|
|
|
|
fn label(&self) -> Option<String> {
|
|
Some("← Go back to commands list".into())
|
|
}
|
|
|
|
async fn on_press(
|
|
&self,
|
|
ctx: InteractionContext<State, Extras>,
|
|
) -> 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<State, Extras> for HelpSupportLinkButton {
|
|
fn label(&self) -> Option<String> {
|
|
Some("Get help".into())
|
|
}
|
|
|
|
fn url(&self) -> Option<String> {
|
|
Some("https://discord.gg/9daSsrfTmE".into())
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct HelpWebsiteLinkButton;
|
|
|
|
#[async_trait]
|
|
impl Button<State, Extras> for HelpWebsiteLinkButton {
|
|
fn label(&self) -> Option<String> {
|
|
Some("Website".into())
|
|
}
|
|
|
|
fn url(&self) -> Option<String> {
|
|
Some("https://payphone.lat/".into())
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct HelpDonateLinkButton;
|
|
|
|
#[async_trait]
|
|
impl Button<State, Extras> for HelpDonateLinkButton {
|
|
fn label(&self) -> Option<String> {
|
|
Some("Donate".into())
|
|
}
|
|
|
|
fn url(&self) -> Option<String> {
|
|
Some("https://ko-fi.com/payphonedev".into())
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct CodeOfConductLinkButton;
|
|
|
|
#[async_trait]
|
|
impl Button<State, Extras> for CodeOfConductLinkButton {
|
|
fn label(&self) -> Option<String> {
|
|
Some("Code of Conduct".into())
|
|
}
|
|
|
|
fn url(&self) -> Option<String> {
|
|
Some("https://payphone.lat/code-of-conduct".into())
|
|
}
|
|
}
|