fixed delete autoresponse
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use crate::{Context, Error};
|
|
||||||
use crate::commands::fun::AiChatKey;
|
use crate::commands::fun::AiChatKey;
|
||||||
|
use crate::{Context, Error};
|
||||||
use poise::serenity_prelude as serenity;
|
use poise::serenity_prelude as serenity;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serenity::prelude::TypeMapKey;
|
use serenity::prelude::TypeMapKey;
|
||||||
@@ -129,12 +129,11 @@ pub async fn delete_auto_response(
|
|||||||
if let Some(record) = record {
|
if let Some(record) = record {
|
||||||
if let Some(mut responses) = record.auto_responses {
|
if let Some(mut responses) = record.auto_responses {
|
||||||
if responses.remove(&msg).is_some() {
|
if responses.remove(&msg).is_some() {
|
||||||
let _: Option<serde::de::IgnoredAny> = db
|
db.query("UPDATE type::thing($thing) SET auto_responses = $responses")
|
||||||
.update(("guilds", guild_id.to_string()))
|
.bind(("thing", ("guilds", guild_id.to_string())))
|
||||||
.merge(serde_json::json!({
|
.bind(("responses", responses))
|
||||||
"auto_responses": responses
|
.await?
|
||||||
}))
|
.check()?;
|
||||||
.await?;
|
|
||||||
ctx.say(format!("Auto-response for `{}` deleted.", msg))
|
ctx.say(format!("Auto-response for `{}` deleted.", msg))
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
@@ -214,8 +213,9 @@ pub async fn edit_auto_response(
|
|||||||
#[poise::command(slash_command, prefix_command, guild_only)]
|
#[poise::command(slash_command, prefix_command, guild_only)]
|
||||||
pub async fn summary(
|
pub async fn summary(
|
||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
#[description = "Message to summarize (reply to one or provide message link)"]
|
#[description = "Message to summarize (reply to one or provide message link)"] message: Option<
|
||||||
message: Option<serenity::Message>,
|
serenity::Message,
|
||||||
|
>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if let poise::Context::Application(app_ctx) = ctx {
|
if let poise::Context::Application(app_ctx) = ctx {
|
||||||
app_ctx.defer().await?;
|
app_ctx.defer().await?;
|
||||||
@@ -239,11 +239,15 @@ pub async fn summary(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let data = ctx.serenity_context().data.read().await;
|
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();
|
let content = msg.content.trim();
|
||||||
|
|
||||||
if content.is_empty() {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ async fn main() -> Result<(), Error> {
|
|||||||
commands::level::set_levelup_message(),
|
commands::level::set_levelup_message(),
|
||||||
commands::fun::say(),
|
commands::fun::say(),
|
||||||
commands::fun::urban(),
|
commands::fun::urban(),
|
||||||
commands::fun::ai_chat(),
|
// commands::fun::ai_chat(),
|
||||||
commands::utility::auto_response(),
|
commands::utility::auto_response(),
|
||||||
commands::utility::view_auto_responses(),
|
commands::utility::view_auto_responses(),
|
||||||
commands::utility::delete_auto_response(),
|
commands::utility::delete_auto_response(),
|
||||||
|
|||||||
Reference in New Issue
Block a user