fixed delete autoresponse

This commit is contained in:
2026-01-24 02:24:48 +05:30
parent da1846585d
commit a5f98266d3
2 changed files with 16 additions and 12 deletions

View File

@@ -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<serde::de::IgnoredAny> = 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<serenity::Message>,
#[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::<AiChatKey>().cloned().ok_or_else(|| anyhow::anyhow!("AI Chat manager not found"))?;
let ai_chat_manager = data
.get::<AiChatKey>()
.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(());
}

View File

@@ -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(),