Add basic moderator commands

This commit is contained in:
2025-08-23 00:02:10 -03:00
parent 8868b18be3
commit eaa38f3474
27 changed files with 752 additions and 249 deletions
+34 -28
View File
@@ -2,7 +2,10 @@ use async_trait::async_trait;
use crate::{
extras::Extras,
framework::interactions::{InteractionError, components::Button, context::InteractionContext},
framework::{
interactions::{InteractionError, components::Button, context::InteractionContext},
messages::MessageEditBuilder,
},
groups::about::embeds::get_all_command_help_embed,
state::State,
};
@@ -12,8 +15,12 @@ pub struct HelpGoBackButton;
#[async_trait]
impl Button<State, Extras> for HelpGoBackButton {
fn label(&self) -> Option<&'static str> {
Some("← Go back to commands list")
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(
@@ -21,16 +28,15 @@ impl Button<State, Extras> for HelpGoBackButton {
ctx: InteractionContext<State, Extras>,
) -> Result<(), InteractionError> {
ctx
.original_message()
.expect(
"Buttons always have the original message in the interaction context, this one didn't (got None)"
.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)
)
.edit()
.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(
@@ -46,12 +52,12 @@ pub struct HelpSupportLinkButton;
#[async_trait]
impl Button<State, Extras> for HelpSupportLinkButton {
fn label(&self) -> Option<&'static str> {
Some("Get help")
fn label(&self) -> Option<String> {
Some("Get help".into())
}
fn url(&self) -> Option<&'static str> {
Some("https://discord.gg/9daSsrfTmE")
fn url(&self) -> Option<String> {
Some("https://discord.gg/9daSsrfTmE".into())
}
}
@@ -60,12 +66,12 @@ pub struct HelpWebsiteLinkButton;
#[async_trait]
impl Button<State, Extras> for HelpWebsiteLinkButton {
fn label(&self) -> Option<&'static str> {
Some("Website")
fn label(&self) -> Option<String> {
Some("Website".into())
}
fn url(&self) -> Option<&'static str> {
Some("https://payphone.lat/")
fn url(&self) -> Option<String> {
Some("https://payphone.lat/".into())
}
}
@@ -74,12 +80,12 @@ pub struct HelpDonateLinkButton;
#[async_trait]
impl Button<State, Extras> for HelpDonateLinkButton {
fn label(&self) -> Option<&'static str> {
Some("Donate")
fn label(&self) -> Option<String> {
Some("Donate".into())
}
fn url(&self) -> Option<&'static str> {
Some("https://ko-fi.com/payphonedev")
fn url(&self) -> Option<String> {
Some("https://ko-fi.com/payphonedev".into())
}
}
@@ -88,11 +94,11 @@ pub struct CodeOfConductLinkButton;
#[async_trait]
impl Button<State, Extras> for CodeOfConductLinkButton {
fn label(&self) -> Option<&'static str> {
Some("Code of Conduct")
fn label(&self) -> Option<String> {
Some("Code of Conduct".into())
}
fn url(&self) -> Option<&'static str> {
Some("https://payphone.lat/code-of-conduct")
fn url(&self) -> Option<String> {
Some("https://payphone.lat/code-of-conduct".into())
}
}