diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index e3d5506344..193a145738 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -49,8 +49,8 @@ module.exports = (_ => { patchPriority: 0, defaults: { settings: { - showToasts: {value: true, description: "Show Plugin start and stop Toasts"}, - showSupportBadges: {value: true, description: "Show little Badges for Users who support my Patreon"} + showToasts: {value: true}, + showSupportBadges: {value: true} } }, }); @@ -457,6 +457,13 @@ module.exports = (_ => { if (typeof key == "string") return BdApi.isSettingEnabled(...key.split(".")); else return oldSettings ? BDFDB.ReactUtils.getValue(BdApi.getBDData("settings"), `${BDFDB.DiscordUtils.getBuilt()}.settings`) : BdApi.settings.map(n => n.settings.map(m => m.settings.map(l => ({id: [n.id, m.id, l.id].join("."), value: l.value})))).flat(10).reduce((newObj, setting) => (newObj[setting.id] = setting.value, newObj), {}); }; + BDFDB.BDUtils.getSettingsProperty = function (property, key) { + if (!window.BdApi || oldSettings) return key ? "" : {}; + else { + let settingsMap = BdApi.settings.map(n => n.settings.map(m => m.settings.map(l => ({id: [n.id, m.id, l.id].join("."), value: l[property]})))).flat(10).reduce((newObj, setting) => (newObj[setting.id] = setting.value, newObj), {}); + return key ? (settingsMap[key] != null ? settingsMap[key] : "") : ""; + } + }; BDFDB.PluginUtils = {}; @@ -485,7 +492,9 @@ module.exports = (_ => { let startMsg = BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", "v" + plugin.version); BDFDB.LogUtils.log(startMsg, plugin.name); - if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${startMsg}`, {nopointer: true}); + if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${startMsg}`, { + noPointer: true + }); if (plugin.css) BDFDB.DOMUtils.appendLocalStyle(plugin.name, plugin.css); @@ -499,7 +508,9 @@ module.exports = (_ => { BDFDB.PluginUtils.clear = function (plugin) { let stopMsg = BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_stopped", "v" + plugin.version); BDFDB.LogUtils.log(stopMsg, plugin.name); - if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${stopMsg}`, {nopointer: true}); + if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${stopMsg}`, { + noPointer: true + }); let url = plugin.rawUrl ||`https://mwittrien.github.io/BetterDiscordAddons/Plugins/${plugin.name}/${plugin.name}.plugin.js`; @@ -564,9 +575,9 @@ module.exports = (_ => { let newVersion = body.match(/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i); if (!newVersion) return callback(null); if (pluginName == newName && BDFDB.NumberUtils.getVersionDifference(newVersion[0], window.PluginUpdates.plugins[url].version) > 0.2) { - BDFDB.NotificationUtils.toast(`${pluginName} will be force updated, because your version is heavily outdated.`, { + BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_force_updated", pluginName), { type: "warn", - nopointer: true + noPointer: true }); BDFDB.PluginUtils.downloadUpdate(pluginName, url); return callback(2); @@ -686,7 +697,10 @@ module.exports = (_ => { if (error) { let updateNotice = document.querySelector("#pluginNotice"); if (updateNotice) BDFDB.PluginUtils.removeUpdateNotice(pluginName, updateNotice); - BDFDB.LogUtils.warn("Unable to get update for " + pluginName); + BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_update_failed", pluginName), { + type: "error", + noPointer: true + }); } else { let wasEnabled = BDFDB.BDUtils.isPluginEnabled(pluginName); @@ -705,7 +719,9 @@ module.exports = (_ => { }); BDFDB.TimeUtils.timeout(_ => {if (wasEnabled && !BDFDB.BDUtils.isPluginEnabled(newName)) BDFDB.BDUtils.enablePlugin(newName);}, 3000); } - BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_updated", pluginName, "v" + oldVersion, newName, "v" + newVersion), {nopointer: true, selector: "plugin-updated-toast"}); + BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_updated", pluginName, "v" + oldVersion, newName, "v" + newVersion), { + noPointer: true + }); let updateNotice = document.querySelector("#pluginNotice"); if (updateNotice) { if (updateNotice.querySelector(BDFDB.dotCN.noticebutton)) { @@ -739,7 +755,7 @@ module.exports = (_ => { type = type.toLowerCase(); let className = BDFDB.disCN["changelog" + type]; if (className) { - changeLogHTML += `