fixes for new users

This commit is contained in:
Zack Rauen 2020-07-26 20:17:15 -04:00
parent 8ec5b5742f
commit 587aeaadf5
1 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,3 @@
import {bdConfig} from "../0globals";
import Utils from "./utils";
import ContentManager from "./contentManager";
@ -6,6 +5,11 @@ const fs = require("fs");
const path = require("path");
const releaseChannel = DiscordNative.globals ? DiscordNative.globals.releaseChannel : DiscordNative.app ? DiscordNative.app.getReleaseChannel() : "stable";
let dataPath = "";
if (process.platform === "win32") dataPath = process.env.APPDATA;
else if (process.platform === "darwin") dataPath = path.join(process.env.HOME, "Library", "Preferences");
else dataPath = path.join(process.env.XDG_CONFIG_HOME ? process.env.XDG_CONFIG_HOME : process.env.HOME, ".config");
export default new class DataStore {
constructor() {
this.data = {settings: {stable: {}, canary: {}, ptb: {}}};
@ -14,6 +18,9 @@ export default new class DataStore {
initialize() {
try {
if (!fs.existsSync(dataPath)) fs.mkdirSync(dataPath);
if (!fs.existsSync(path.join(dataPath, "plugins"))) fs.mkdirSync(path.join(dataPath, "plugins"));
if (!fs.existsSync(path.join(dataPath, "themes"))) fs.mkdirSync(path.join(dataPath, "themes"));
if (!fs.existsSync(this.BDFile)) fs.writeFileSync(this.BDFile, JSON.stringify(this.data, null, 4));
const data = __non_webpack_require__(this.BDFile);
if (data.hasOwnProperty("settings")) this.data = data;
@ -43,8 +50,8 @@ export default new class DataStore {
}
get configFile() {return this._configFile || (this._configFile = path.resolve(this.injectionPath, "betterdiscord", "config.json"));}
get BDFile() {return this._BDFile || (this._BDFile = path.resolve(bdConfig.dataPath, "bdstorage.json"));}
get settingsFile() {return this._settingsFile || (this._settingsFile = path.resolve(bdConfig.dataPath, "bdsettings.json"));}
get BDFile() {return this._BDFile || (this._BDFile = path.resolve(dataPath, "bdstorage.json"));}
get settingsFile() {return this._settingsFile || (this._settingsFile = path.resolve(dataPath, "bdsettings.json"));}
getPluginFile(pluginName) {return path.resolve(ContentManager.pluginsFolder, pluginName + ".config.json");}
getSettingGroup(key) {