From cdcd7a8035d6984bbf2cda6186b57942695d7b80 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 3 Feb 2021 12:02:17 +0100 Subject: [PATCH] Update 0BDFDB.plugin.js --- Library/0BDFDB.plugin.js | 46 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 3b65f23bef..1e195ff20b 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -4120,41 +4120,45 @@ module.exports = (_ => { } else window.open(url, "_blank"); }; + window.DiscordNative && window.DiscordNative.app && window.DiscordNative.app.getPath("appData").then(path => {BDFDB.DiscordUtils.getFolder.base = path;}); BDFDB.DiscordUtils.getFolder = function () { - if (!LibraryRequires.electron || !LibraryRequires.electron.remote) return ""; - let built = BDFDB.DiscordUtils.getBuilt(); - built = "discord" + (built == "stable" ? "" : built); - return LibraryRequires.path.resolve(LibraryRequires.electron.remote.app.getPath("appData"), built, BDFDB.DiscordUtils.getVersion()); + if (!BDFDB.DiscordUtils.getFolder.base) return ""; + else if (BDFDB.DiscordUtils.getFolder.folder) return BDFDB.DiscordUtils.getFolder.folder; + else { + let folder; + try { + let built = BDFDB.DiscordUtils.getBuilt(); + built = "discord" + (built == "stable" ? "" : built); + folder = LibraryRequires.path.resolve(BDFDB.DiscordUtils.getFolder.base, built, BDFDB.DiscordUtils.getVersion()); + } + catch (err) {folder = BDFDB.DiscordUtils.getFolder.base;} + return BDFDB.DiscordUtils.getFolder.folder = folder; + } }; BDFDB.DiscordUtils.getBuilt = function () { if (BDFDB.DiscordUtils.getBuilt.built) return BDFDB.DiscordUtils.getBuilt.built; else { - let built = null; - try {built = require(LibraryRequires.electron.remote.app.getAppPath() + "/build_info.json").releaseChannel.toLowerCase();} + let built; + try {built = window.DiscordNative.app.getReleaseChannel();} catch (err) { - try {built = require(LibraryRequires.electron.remote.app.getAppPath().replace("\app.asar", "") + "/build_info.json").releaseChannel.toLowerCase();} - catch (err) { - let version = BDFDB.DiscordUtils.getVersion(); - if (version) { - version = version.split("."); - if (version.length == 3 && !isNaN(version = parseInt(version[2]))) built = version > 300 ? "stable" : version > 200 ? "canary" : "ptb"; - else built = "stable"; - } + let version = BDFDB.DiscordUtils.getVersion(); + if (version) { + version = version.split("."); + if (version.length == 3 && !isNaN(version = parseInt(version[2]))) built = version > 300 ? "stable" : version > 200 ? "canary" : "ptb"; else built = "stable"; } + else built = "stable"; } - BDFDB.DiscordUtils.getBuilt.built = built; - return built; + return BDFDB.DiscordUtils.getBuilt.built = built; } }; BDFDB.DiscordUtils.getVersion = function () { if (BDFDB.DiscordUtils.getVersion.version) return BDFDB.DiscordUtils.getVersion.version; else { - let version = null; - try {version = LibraryModules.WindowUtils.version.join(".");} - catch (err) {version = "999.999.999";} - BDFDB.DiscordUtils.getVersion.version = version; - return version; + let version; + try {version = window.DiscordNative.app.getVersion();} + catch (err) {version = "999.999.9999";} + return BDFDB.DiscordUtils.getVersion.version = version; } }; BDFDB.DiscordUtils.isDevModeEnabled = function () {