lot of refactor
This commit is contained in:
@@ -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" }
|
||||
@@ -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(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod functions;
|
||||
Reference in New Issue
Block a user