Auto-Generate Config (#29)

* fix: name in job

* add: auto create config.json on missing

* update: readme goals

* add: clarify instructions on fail chat

* update: reduced redundancy in package file
This commit is contained in:
Kevin Dang
2024-03-30 22:02:49 -07:00
committed by GitHub
parent 9320a7476e
commit 6b903cff5e
5 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import { ChatResponse } from 'ollama'
import { embedMessage, event, Events, normalMessage } from '../utils/index.js'
import { Configuration, getConfig } from '../utils/jsonHandler.js'
import { Configuration, getConfig, openFile } from '../utils/jsonHandler.js'
/**
* Max Message length for free users is 2000 characters (bot or not).
@@ -54,6 +54,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, tokens, ollama
})
} catch (error: any) {
msgHist.pop() // remove message because of failure
message.reply(`**Response generation failed.**\n\nReason: ${error.message}\n\nPlease use any config slash command.`)
openFile('config.json', 'message-style', true)
message.reply(`**Response generation failed.**\n\n**Reason:** *${error.message}*\n\nCreating \`config.json\` with \`message-style\` set as \`true\` for embedded messages.\nPlease try chatting again.`)
}
})