From 48ca031ccd61f5930f537bed436b34ae8abd4b25 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Thu, 20 Jun 2024 00:29:13 +0200 Subject: [PATCH] stuff --- Library/0BDFDB.plugin.js | 17 +++++++++++++++-- Library/_res/0BDFDB.data.json | 5 ++++- Plugins/EditChannels/EditChannels.plugin.js | 2 +- .../SplitLargeMessages.plugin.js | 2 +- Plugins/Translator/Translator.plugin.js | 4 ++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 169f7d1837..b343f60193 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -1410,7 +1410,14 @@ module.exports = (_ => { return BDFDB.ArrayUtils.removeCopies([firstReturn].concat(secondReturn).flat(10)); }; - const DiscordConstantsObject = BDFDB.ModuleUtils.findByProperties("AnalyticsSections", "ChannelTypes", "MessageTypes"); + const DiscordConstantsObject = BDFDB.ModuleUtils.find(m => {try { + if (!m || !Object.keys(m)) return; + if ([["CUSTOM_STATUS", "STREAMING", "WATCHING"], ["GUILD_TEXT", "GUILD_FORUM", "GUILD_STORE"], ["THREAD_CREATED", "CHAT_INPUT_COMMAND"]].every(array => Object.keys(m).some(k => { + if (!m[k]) return false; + let keys = Object.keys(m[k]); + if (keys && array.every(n => keys.indexOf(n) > -1)) return true; + }))) return m; + } catch (err) {}}); if (InternalData.CustomDiscordConstants) DiscordConstants = Object.assign(DiscordConstants, InternalData.CustomDiscordConstants); if (DiscordConstantsObject) DiscordConstants = Object.assign(DiscordConstants, DiscordConstantsObject); Internal.DiscordConstants = new Proxy(DiscordConstants, { @@ -1421,7 +1428,13 @@ module.exports = (_ => { return {}; } if (InternalData.DiscordConstants[item].strings) DiscordConstants[item] = BDFDB.ModuleUtils.findByString(InternalData.DiscordConstants[item].strings); - else DiscordConstants[item] = BDFDB.ModuleUtils.findByProperties(InternalData.DiscordConstants[item]); + else { + if (DiscordConstantsObject) DiscordConstants[item] = DiscordConstantsObject[Object.keys(DiscordConstantsObject).find(n => { + let keys = Object.keys(DiscordConstantsObject[n]); + if (keys && InternalData.DiscordConstants[item].every(k => keys.indexOf(n) > -1)) return true; + })]; + if (!DiscordConstants[item]) DiscordConstants[item] = BDFDB.ModuleUtils.findByProperties(InternalData.DiscordConstants[item]); + } if (InternalData.DiscordConstants[item].value) DiscordConstants[item] = DiscordConstants[item][InternalData.DiscordConstants[item].value] || DiscordConstants[item]; return DiscordConstants[item] ? DiscordConstants[item] : {}; } diff --git a/Library/_res/0BDFDB.data.json b/Library/_res/0BDFDB.data.json index 9951b492db..8bde26ff7d 100644 --- a/Library/_res/0BDFDB.data.json +++ b/Library/_res/0BDFDB.data.json @@ -68,13 +68,16 @@ "UserPremiumLevels": {"1": 1, "2": 2, "3": 3, "4": 6, "5": 9, "6": 12, "7": 15, "8": 18, "9": 24} }, "DiscordConstants": { + "ActivityTypes": ["CUSTOM_STATUS", "STREAMING", "WATCHING"], + "AnalyticsSections": ["FRIENDS_LIST", "PROFILE_POPOUT", "ACCOUNT_PANEL"], "AutocompleterResultTypes": ["VOICE_CHANNEL", "TEXT_CHANNEL", "USER", "LINK"], "ChannelTextAreaTypes": ["CREATE_FORUM_POST", "PROFILE_BIO_INPUT", "FORUM_CHANNEL_GUIDELINES"], - "Colors": ["SPOTIFY", "RED_100", "BLUE"], "ColorsCSS": {"strings": ["var(--status-positive", "var(--bg-brand)"], "value": "Z"}, "EmojiSprites": ["DiversityPerRow", "PickerCount", "PickerPerRow"], "InboxTabs": ["MENTIONS", "UNREADS"], + "MessageTypes": ["THREAD_CREATED", "CHAT_INPUT_COMMAND"], "MessageTypeGroups": ["USER_MESSAGE", "UNDELETABLE"], + "Permissions": ["MOVE_MEMBERS", "ADD_REACTIONS", "USE_EXTERNAL_APPS", "VIEW_CREATOR_MONETIZATION_ANALYTICS"], "ReadStateTypes": ["GUILD_EVENT", "NOTIFICATION_CENTER", "CHANNEL"], "UserSettingsActionTypes": ["SLOW_USER_ACTION", "DAILY"] }, diff --git a/Plugins/EditChannels/EditChannels.plugin.js b/Plugins/EditChannels/EditChannels.plugin.js index 9451de02f3..1978e48834 100644 --- a/Plugins/EditChannels/EditChannels.plugin.js +++ b/Plugins/EditChannels/EditChannels.plugin.js @@ -271,7 +271,7 @@ module.exports = (_ => { } processChannelTextAreaEditor (e) { - if (!this.settings.places.chatTextarea || e.instance.props.disabled || !e.instance.props.channel || !changedChannels[e.instance.props.channel.id] || e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return; + if (!this.settings.places.chatTextarea || e.instance.props.disabled || !e.instance.props.channel || !changedChannels[e.instance.props.channel.id] || e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return; if (changedChannels[e.instance.props.channel.id].name) e.instance.props.placeholder = BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", `#${changedChannels[e.instance.props.channel.id].name}`); } diff --git a/Plugins/SplitLargeMessages/SplitLargeMessages.plugin.js b/Plugins/SplitLargeMessages/SplitLargeMessages.plugin.js index 820cd71854..a65cfa2370 100644 --- a/Plugins/SplitLargeMessages/SplitLargeMessages.plugin.js +++ b/Plugins/SplitLargeMessages/SplitLargeMessages.plugin.js @@ -164,7 +164,7 @@ module.exports = (_ => { } processChannelTextAreaContainer (e) { - if (e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY && e.instance.props.type != BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) return; + if (e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) return; const splitMessageLength = this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter; if (!e.returnvalue) { BDFDB.PatchUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => { diff --git a/Plugins/Translator/Translator.plugin.js b/Plugins/Translator/Translator.plugin.js index eca5fdfeaf..4fc4d29c6a 100644 --- a/Plugins/Translator/Translator.plugin.js +++ b/Plugins/Translator/Translator.plugin.js @@ -679,7 +679,7 @@ module.exports = (_ => { } processChannelTextAreaContainer (e) { - if (e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return; + if (e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return; BDFDB.PatchUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => { if (this.isTranslationEnabled(e.instance.props.channel.id) && e2.methodArguments[0].value) { e2.stopOriginalMethodCall(); @@ -701,7 +701,7 @@ module.exports = (_ => { } processChannelTextAreaButtons (e) { - if (!this.settings.general.addTranslateButton || e.instance.props.disabled || e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return; + if (!this.settings.general.addTranslateButton || e.instance.props.disabled || e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return; if (e.returnvalue) e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(TranslateButtonComponent, { guildId: e.instance.props.channel.guild_id ? e.instance.props.channel.guild_id : "@me", channelId: e.instance.props.channel.id