* add: validate thread creation in ollama channel * rm: channel_id variable * add: short notes for threads * update: openFile to openConfig for clarity * update: test ci runs on master * add: notes for work * add: basic chat storing via json * update: stores entire msgHist according to capacity * add: removes json file if thread is deleted * add: chats with independent histories * add: private vs public threads * update: validate threads made by ollama for chats * update: cleanup and version increment
20 lines
645 B
TypeScript
20 lines
645 B
TypeScript
import { ThreadChannel } from 'discord.js'
|
|
import { event, Events } from '../utils/index.js'
|
|
import fs from 'fs'
|
|
|
|
/**
|
|
* Event to remove the associated .json file for a thread once deleted
|
|
*/
|
|
export default event(Events.ThreadDelete, ({ log }, thread: ThreadChannel) => {
|
|
const filePath = `data/${thread.id}.json`
|
|
if (fs.existsSync(filePath)) {
|
|
fs.unlink(filePath, (error) => {
|
|
if (error)
|
|
log(`Error deleting file ${filePath}`, error)
|
|
else
|
|
log(`Successfully deleted ${filePath} thread info`)
|
|
})
|
|
} else {
|
|
log(`File ${filePath} does not exist.`)
|
|
}
|
|
}) |