Siren OAI creates thread if possible for conversations

This commit is contained in:
2023-07-07 12:24:04 -04:00
parent b09b09453a
commit 7d94f07329
2 changed files with 17 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ use log::{error, debug, trace, warn};
use serde::{Serialize, Deserialize};
use serde_json::Value;
use serenity::model::channel::Message;
use serenity::model::prelude::ChannelType;
use serenity::prelude::*;
use crate::database::models::{NewMessageDB, MessageDB};
@@ -288,7 +289,18 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI, pool: &P
// Stop the typing indicator and send the response
typing.stop();
if let Err(why) = msg.channel_id.say(&ctx.http, response).await {
error!("Cannot send message: {}", why);
}
match msg.channel_id.create_public_thread(&ctx.http, msg.id, |thread| {
thread.name("Siren Response").kind(ChannelType::PublicThread)
}).await {
Ok(c) => {
if let Err(why) = c.say(&ctx.http, response).await {
error!("Cannot send message: {}", why);
}
}
Err(_) => {
if let Err(why) = channel_id.say(&ctx.http, response).await {
error!("Cannot send message: {}", why);
}
}
};
}