From 78f6afb11467011181a1481c5e1518ef56428b15 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Thu, 29 Sep 2022 18:46:33 +0200 Subject: [PATCH] Update 0BDFDB.plugin.js --- Library/0BDFDB.plugin.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 98b16025c7..9fab627a37 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -4360,6 +4360,22 @@ module.exports = (_ => { }; BDFDB.DiscordUtils = {}; + BDFDB.DiscordUtils.getSetting = function (category, key) { + if (!category || !key) return; + return BDFDB.LibraryStores.UserSettingsProtoStore && BDFDB.LibraryStores.UserSettingsProtoStore.settings[category] && BDFDB.LibraryStores.UserSettingsProtoStore.settings[category][key] && BDFDB.LibraryStores.UserSettingsProtoStore.settings[category][key].value; + }; + BDFDB.DiscordUtils.setSetting = function (category, key, value) { + if (!category || !key) return; + let store = BDFDB.DiscordUtils.getSettingsStore(); + if (store) store.updateAsync("status", settings => { + if (!settings) return; + if (!settings[key]) settings[key] = {}; + settings[key].value = value; + }, Internal.DiscordConstants.UserSettingsActionTypes.INFREQUENT_USER_ACTION); + }; + BDFDB.DiscordUtils.getSettingsStore = function () { + return BDFDB.LibraryModules.UserSettingsProtoUtils && (Object.entries(BDFDB.LibraryModules.UserSettingsProtoUtils).find(n => n && n[1] && n[1].updateAsync && n[1].ProtoClass && n[1].ProtoClass.typeName && n[1].ProtoClass.typeName.endsWith(".PreloadedUserSettings")) || [])[1]; + }; BDFDB.DiscordUtils.openLink = function (url, config = {}) { if ((config.inBuilt || config.inBuilt === undefined && Internal.settings.general.useChromium) && Internal.LibraryRequires.electron && Internal.LibraryRequires.electron.remote) { let browserWindow = new Internal.LibraryRequires.electron.remote.BrowserWindow({