debug: add more info

This commit is contained in:
tretrauit 2023-12-31 23:49:07 +07:00
parent 34c52cd9ab
commit 9536539e8c
3 changed files with 44 additions and 27 deletions

View File

@ -1,20 +1,21 @@
use serenity::client::Context;
use serenity::model::channel::Message;
use serenity::builder::CreateMessage;
use crate::template::message;
pub async fn error_message(ctx: &Context, msg: &Message, content: String) {
msg.channel_id
.send_message(
ctx,
CreateMessage::new().add_embed(
message::error_embed(
ctx,
None,
Some(content),
)
.await,
),
)
.await?;
}
use crate::template::message;
use serenity::builder::CreateMessage;
use serenity::client::Context;
use serenity::model::channel::Message;
use swordfish_common::error;
pub async fn error_message(ctx: &Context, msg: &Message, content: String) {
match msg
.channel_id
.send_message(
ctx,
CreateMessage::new().add_embed(message::error_embed(ctx, None, Some(content)).await),
)
.await
{
Ok(_) => (),
Err(why) => {
error!("Failed to send error message: {:?}", why);
}
};
}

View File

@ -12,7 +12,10 @@ use swordfish_common::{debug, error, info, trace, warn};
pub fn analyze_card(leptess: &LepTess, card: image::DynamicImage) {
trace!("Analyzing card...");
// Read the name and the series
let name_img = card.crop_imm(0, 0, 257, 29);
let name_img = card.crop_imm(22, 26, 206 - 22, 70 - 26);
name_img.save("debug/4-name.png").unwrap();
let series_img = card.crop_imm(22, 260, 206 - 22, 306 - 260);
series_img.save("debug/4-series.png").unwrap();
// Read the print number
}

View File

@ -57,7 +57,7 @@ async fn parse_katana(ctx: &Context, msg: &Message) -> Result<(), String> {
{
trace!("Card drop detected, executing drop analyzer...");
unsafe {
match katana::analyze_drop_message(&LEPTESS_ARC, msg) {
match katana::analyze_drop_message(&LEPTESS_ARC, msg).await {
Ok(_) => {
// msg.reply(ctx, "Drop analysis complete").await?;
}
@ -120,12 +120,18 @@ async fn kdropanalyze(ctx: &Context, msg: &Message) -> CommandResult {
Some(content) => match content.parse::<u64>() {
Ok(id) => id,
Err(why) => {
helper::error_message(ctx, msg, format!("Failed to parse channel ID: `{:?}`", why)).await;
helper::error_message(ctx, msg, format!("Failed to parse channel ID: `{:?}`", why))
.await;
return Ok(());
}
},
None => {
helper::error_message(ctx, msg, "Usage: `kdropanalyze <channel ID> <message ID>`".to_string()).await;
helper::error_message(
ctx,
msg,
"Usage: `kdropanalyze <channel ID> <message ID>`".to_string(),
)
.await;
return Ok(());
}
};
@ -133,12 +139,18 @@ async fn kdropanalyze(ctx: &Context, msg: &Message) -> CommandResult {
Some(content) => match content.parse::<u64>() {
Ok(id) => id,
Err(why) => {
helper::error_message(ctx, msg, format!("Failed to parse message ID: `{:?}`", why)).await;
helper::error_message(ctx, msg, format!("Failed to parse message ID: `{:?}`", why))
.await;
return Ok(());
}
},
None => {
helper::error_message(ctx, msg, "Usage: `kdropanalyze <channel ID> <message ID>`".to_string()).await;
helper::error_message(
ctx,
msg,
"Usage: `kdropanalyze <channel ID> <message ID>`".to_string(),
)
.await;
return Ok(());
}
};
@ -162,7 +174,8 @@ async fn kdropanalyze(ctx: &Context, msg: &Message) -> CommandResult {
msg.reply(ctx, "Drop analysis complete").await?;
}
Err(why) => {
helper::error_message(ctx, msg, format!("Failed to analyze drop: `{:?}`", why)).await;
helper::error_message(ctx, msg, format!("Failed to analyze drop: `{:?}`", why))
.await;
}
};
}