mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 11:56:06 -05:00
Update: utility method logs use method name
This commit is contained in:
@@ -64,7 +64,7 @@ export async function clearChannelInfo(filename: string, channel: TextChannel, u
|
|||||||
* @param user the user's name
|
* @param user the user's name
|
||||||
* @param messages their messages
|
* @param messages their messages
|
||||||
*/
|
*/
|
||||||
export async function openChannelInfo(filename: string, channel: TextChannel | ThreadChannel, user: string, messages: UserMessage[] = []): Promise<void> {
|
export async function openChannelInfo(this: any, filename: string, channel: TextChannel | ThreadChannel, user: string, messages: UserMessage[] = []): Promise<void> {
|
||||||
const fullFileName = `data/${filename}-${user}.json`
|
const fullFileName = `data/${filename}-${user}.json`
|
||||||
if (fs.existsSync(fullFileName)) {
|
if (fs.existsSync(fullFileName)) {
|
||||||
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
||||||
@@ -95,7 +95,7 @@ export async function openChannelInfo(filename: string, channel: TextChannel | T
|
|||||||
|
|
||||||
// only creating it, no need to add anything
|
// only creating it, no need to add anything
|
||||||
fs.writeFileSync(fullFileName, JSON.stringify(object, null, 2))
|
fs.writeFileSync(fullFileName, JSON.stringify(object, null, 2))
|
||||||
console.log(`[Util: openChannelInfo] Created '${fullFileName}' in working directory`)
|
console.log(`[Util: ${this.name}] Created '${fullFileName}' in working directory`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import path from 'path'
|
|||||||
* @param value new value to assign
|
* @param value new value to assign
|
||||||
*/
|
*/
|
||||||
// add type of change (server, user)
|
// add type of change (server, user)
|
||||||
export function openConfig(filename: string, key: string, value: any) {
|
export function openConfig(this: any, filename: string, key: string, value: any) {
|
||||||
const fullFileName = `data/${filename}`
|
const fullFileName = `data/${filename}`
|
||||||
|
|
||||||
// check if the file exists, if not then make the config file
|
// check if the file exists, if not then make the config file
|
||||||
@@ -41,7 +41,7 @@ export function openConfig(filename: string, key: string, value: any) {
|
|||||||
fs.mkdirSync(directory, { recursive: true })
|
fs.mkdirSync(directory, { recursive: true })
|
||||||
|
|
||||||
fs.writeFileSync(`data/${filename}`, JSON.stringify(object, null, 2))
|
fs.writeFileSync(`data/${filename}`, JSON.stringify(object, null, 2))
|
||||||
console.log(`[Util: openConfig] Created '${filename}' in working directory`)
|
console.log(`[Util: ${this.name}] Created '${filename}' in working directory`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { AbortableAsyncIterator } from 'ollama/src/utils.js'
|
|||||||
* @param msgHist message history between user and model
|
* @param msgHist message history between user and model
|
||||||
*/
|
*/
|
||||||
export async function normalMessage(
|
export async function normalMessage(
|
||||||
|
this: any,
|
||||||
message: Message,
|
message: Message,
|
||||||
ollama: Ollama,
|
ollama: Ollama,
|
||||||
model: string,
|
model: string,
|
||||||
@@ -73,7 +74,7 @@ export async function normalMessage(
|
|||||||
sentMessage.edit(result)
|
sentMessage.edit(result)
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(`[Util: messageNormal] Error creating message: ${error.message}`)
|
console.log(`[Util: ${this.name}] Error creating message: ${error.message}`)
|
||||||
if (error.message.includes('try pulling it first'))
|
if (error.message.includes('try pulling it first'))
|
||||||
sentMessage.edit(`**Response generation failed.**\n\nReason: You do not have the ${model} downloaded. Ask an admin to pull it using the \`pull-model\` command.`)
|
sentMessage.edit(`**Response generation failed.**\n\nReason: You do not have the ${model} downloaded. Ask an admin to pull it using the \`pull-model\` command.`)
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user