From a5f98266d3fc279751c5e681d7ae64f526956a1d Mon Sep 17 00:00:00 2001 From: Kishor Date: Sat, 24 Jan 2026 02:24:48 +0530 Subject: [PATCH] fixed delete autoresponse --- src/commands/utility.rs | 26 +++++++++++++++----------- src/main.rs | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/commands/utility.rs b/src/commands/utility.rs index c0986cd..55edadc 100644 --- a/src/commands/utility.rs +++ b/src/commands/utility.rs @@ -1,5 +1,5 @@ -use crate::{Context, Error}; use crate::commands::fun::AiChatKey; +use crate::{Context, Error}; use poise::serenity_prelude as serenity; use serde::{Deserialize, Serialize}; use serenity::prelude::TypeMapKey; @@ -129,12 +129,11 @@ pub async fn delete_auto_response( if let Some(record) = record { if let Some(mut responses) = record.auto_responses { if responses.remove(&msg).is_some() { - let _: Option = db - .update(("guilds", guild_id.to_string())) - .merge(serde_json::json!({ - "auto_responses": responses - })) - .await?; + db.query("UPDATE type::thing($thing) SET auto_responses = $responses") + .bind(("thing", ("guilds", guild_id.to_string()))) + .bind(("responses", responses)) + .await? + .check()?; ctx.say(format!("Auto-response for `{}` deleted.", msg)) .await?; } else { @@ -214,8 +213,9 @@ pub async fn edit_auto_response( #[poise::command(slash_command, prefix_command, guild_only)] pub async fn summary( ctx: Context<'_>, - #[description = "Message to summarize (reply to one or provide message link)"] - message: Option, + #[description = "Message to summarize (reply to one or provide message link)"] message: Option< + serenity::Message, + >, ) -> Result<(), Error> { if let poise::Context::Application(app_ctx) = ctx { app_ctx.defer().await?; @@ -239,11 +239,15 @@ pub async fn summary( }; let data = ctx.serenity_context().data.read().await; - let ai_chat_manager = data.get::().cloned().ok_or_else(|| anyhow::anyhow!("AI Chat manager not found"))?; + let ai_chat_manager = data + .get::() + .cloned() + .ok_or_else(|| anyhow::anyhow!("AI Chat manager not found"))?; let content = msg.content.trim(); if content.is_empty() { - ctx.say("The message is empty, nothing to summarize.").await?; + ctx.say("The message is empty, nothing to summarize.") + .await?; return Ok(()); } diff --git a/src/main.rs b/src/main.rs index 6ce2cb3..e1b3835 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,7 @@ async fn main() -> Result<(), Error> { commands::level::set_levelup_message(), commands::fun::say(), commands::fun::urban(), - commands::fun::ai_chat(), + // commands::fun::ai_chat(), commands::utility::auto_response(), commands::utility::view_auto_responses(), commands::utility::delete_auto_response(),