lot of refactor

This commit is contained in:
2026-03-14 19:21:56 +01:00
parent b63982714b
commit 8d4a002b73
22 changed files with 256 additions and 313 deletions
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "serenity-libs"
version = "0.1.0"
edition = "2024"
[dependencies]
async-trait = { version = "0.1.89" }
serenity = { version = "0.12.5", default-features = false }
types = { path = "../../libs/types" }
+49
View File
@@ -0,0 +1,49 @@
use async_trait::async_trait;
use serenity::all::{
CommandInteraction,
Context,
CreateInteractionResponse,
CreateInteractionResponseMessage,
EditInteractionResponse,
};
use types::error::{CorroError, CorroErrorType};
#[async_trait]
pub trait CustomInteraction {
async fn create_text_response(&self, ctx: &Context, content: String) -> Result<(), CorroError>;
async fn edit_text_response(&self, ctx: &Context, content: String) -> Result<(), CorroError>;
}
#[async_trait]
impl CustomInteraction for CommandInteraction {
async fn create_text_response(&self, ctx: &Context, content: String) -> Result<(), CorroError> {
match self
.create_response(
&ctx,
CreateInteractionResponse::Message(
CreateInteractionResponseMessage::new().content(&content),
),
)
.await
{
Ok(_) => Ok(()),
Err(why) => Err(CorroError {
error_type: CorroErrorType::SerenityError,
message: why.to_string(),
}),
}
}
async fn edit_text_response(&self, ctx: &Context, content: String) -> Result<(), CorroError> {
match self
.edit_response(&ctx, EditInteractionResponse::new().content(&content))
.await
{
Ok(_) => Ok(()),
Err(why) => Err(CorroError {
error_type: CorroErrorType::SerenityError,
message: why.to_string(),
}),
}
}
}
+1
View File
@@ -0,0 +1 @@
pub mod functions;