Data Directory on Chat for Preferences (#105)

* Fix: data directory created on for openConfig

* Update: version increment
This commit is contained in:
Kevin Dang
2024-08-03 09:50:03 -07:00
committed by GitHub
parent af23db20bb
commit 42ef38db14
4 changed files with 9 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ services:
build: ./ # find docker file in designated path
container_name: discord
restart: always # rebuild container always
image: kevinthedang/discord-ollama:0.5.8
image: kevinthedang/discord-ollama:0.5.9
environment:
CLIENT_TOKEN: ${CLIENT_TOKEN}
GUILD_ID: ${GUILD_ID}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "discord-ollama",
"version": "0.5.8",
"version": "0.5.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "discord-ollama",
"version": "0.5.8",
"version": "0.5.9",
"license": "ISC",
"dependencies": {
"discord.js": "^14.15.3",

View File

@@ -1,6 +1,6 @@
{
"name": "discord-ollama",
"version": "0.5.8",
"version": "0.5.9",
"description": "Ollama Integration into discord",
"main": "build/index.js",
"exports": "./build/index.js",

View File

@@ -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`)
}