mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-13 03:56:07 -05:00
Data Directory on Chat for Preferences (#105)
* Fix: data directory created on for openConfig * Update: version increment
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Configuration, ServerConfig, UserConfig, isServerConfigurationKey } from '../index.js'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
/**
|
||||
* Method to open a file in the working directory and modify/create it
|
||||
@@ -35,6 +36,10 @@ export function openConfig(filename: string, key: string, value: any) {
|
||||
[key]: value
|
||||
}
|
||||
|
||||
const directory = path.dirname(fullFileName)
|
||||
if (!fs.existsSync(directory))
|
||||
fs.mkdirSync(directory, { recursive: true })
|
||||
|
||||
fs.writeFileSync(`data/${filename}`, JSON.stringify(object, null, 2))
|
||||
console.log(`[Util: openConfig] Created '${filename}' in working directory`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user