From d95be1acbaa282c53508a33d85cdda2ea76c50da Mon Sep 17 00:00:00 2001 From: fawn Date: Fri, 10 Feb 2023 21:41:49 +0000 Subject: [PATCH] refactor: update plugins to use `$self` (#478) Co-authored-by: Ven --- src/plugins/anonymiseFileNames.ts | 2 +- src/plugins/betterGifAltText.ts | 4 ++-- src/plugins/betterRoleDot.ts | 2 +- src/plugins/callTimer.tsx | 2 +- src/plugins/emoteCloner.tsx | 2 +- src/plugins/forceOwnerCrown.ts | 2 +- src/plugins/ignoreActivities.tsx | 6 +++--- src/plugins/loadingQuotes.ts | 2 +- src/plugins/memberCount.tsx | 2 +- src/plugins/messageLogger/index.tsx | 8 ++++---- src/plugins/noBlockedMessages.ts | 2 +- src/plugins/noReplyMention.tsx | 2 +- src/plugins/pronoundb/index.ts | 4 ++-- src/plugins/reviewDB/index.tsx | 2 +- src/plugins/spotifyControls/index.tsx | 2 +- src/plugins/startupTimings/index.tsx | 2 +- src/plugins/vcDoubleClick.ts | 2 +- src/plugins/viewIcons.tsx | 2 +- src/plugins/whoReacted.tsx | 2 +- 19 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/plugins/anonymiseFileNames.ts b/src/plugins/anonymiseFileNames.ts index f953a144e..26c423c0a 100644 --- a/src/plugins/anonymiseFileNames.ts +++ b/src/plugins/anonymiseFileNames.ts @@ -36,7 +36,7 @@ export default definePlugin({ replacement: { match: /uploadFiles:(.{1,2}),/, replace: - "uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=Vencord.Plugins.plugins.AnonymiseFileNames.anonymise(f.filename)),$1(...args)),", + "uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=$self.anonymise(f.filename)),$1(...args)),", }, }, ], diff --git a/src/plugins/betterGifAltText.ts b/src/plugins/betterGifAltText.ts index 686ef0a55..5e0191b9d 100644 --- a/src/plugins/betterGifAltText.ts +++ b/src/plugins/betterGifAltText.ts @@ -31,7 +31,7 @@ export default definePlugin({ replacement: { match: /(return.{0,10}\.jsx.{0,50}isWindowFocused)/, replace: - "Vencord.Plugins.plugins.BetterGifAltText.altify(e);$1", + "$self.altify(e);$1", }, }, { @@ -39,7 +39,7 @@ export default definePlugin({ replacement: { match: /(?<==(.{1,3})\.alt.{0,20})\?.{0,5}\.Messages\.GIF/, replace: - "?($1.alt='GIF',Vencord.Plugins.plugins.BetterGifAltText.altify($1))", + "?($1.alt='GIF',$self.altify($1))", }, }, ], diff --git a/src/plugins/betterRoleDot.ts b/src/plugins/betterRoleDot.ts index 6cadf7915..6ef92a863 100644 --- a/src/plugins/betterRoleDot.ts +++ b/src/plugins/betterRoleDot.ts @@ -33,7 +33,7 @@ export default definePlugin({ find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z", replacement: { match: /viewBox:"0 0 20 20"/, - replace: "$&,onClick:()=>Vencord.Plugins.plugins.BetterRoleDot.copyToClipBoard(e.color),style:{cursor:'pointer'}", + replace: "$&,onClick:()=>$self.copyToClipBoard(e.color),style:{cursor:'pointer'}", }, }, { diff --git a/src/plugins/callTimer.tsx b/src/plugins/callTimer.tsx index ff0225647..f745bf625 100644 --- a/src/plugins/callTimer.tsx +++ b/src/plugins/callTimer.tsx @@ -75,7 +75,7 @@ export default definePlugin({ find: ".renderConnectionStatus=", replacement: { match: /(?<=renderConnectionStatus=.+\.channel,children:)\w/, - replace: "[$&, Vencord.Plugins.plugins.CallTimer.renderTimer(this.props.channel.id)]" + replace: "[$&, $self.renderTimer(this.props.channel.id)]" } }], renderTimer(channelId: string) { diff --git a/src/plugins/emoteCloner.tsx b/src/plugins/emoteCloner.tsx index bb744060f..15d13588d 100644 --- a/src/plugins/emoteCloner.tsx +++ b/src/plugins/emoteCloner.tsx @@ -187,7 +187,7 @@ export default definePlugin({ find: "open-native-link", replacement: { match: /id:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\},"open-native-link"\)/, - replace: "$&,Vencord.Plugins.plugins.EmoteCloner.makeMenu(arguments[2])" + replace: "$&,$self.makeMenu(arguments[2])" }, }, diff --git a/src/plugins/forceOwnerCrown.ts b/src/plugins/forceOwnerCrown.ts index 0c1df4780..3122410f9 100644 --- a/src/plugins/forceOwnerCrown.ts +++ b/src/plugins/forceOwnerCrown.ts @@ -30,7 +30,7 @@ export default definePlugin({ find: ".renderOwner=", replacement: { match: /isOwner;return null!=(\w+)?&&/g, - replace: "isOwner;if(Vencord.Plugins.plugins.ForceOwnerCrown.isGuildOwner(this.props)){$1=true;}return null!=$1&&" + replace: "isOwner;if($self.isGuildOwner(this.props)){$1=true;}return null!=$1&&" } }, ], diff --git a/src/plugins/ignoreActivities.tsx b/src/plugins/ignoreActivities.tsx index 300caf7aa..56a0a8dba 100644 --- a/src/plugins/ignoreActivities.tsx +++ b/src/plugins/ignoreActivities.tsx @@ -146,19 +146,19 @@ export default definePlugin({ find: ".Messages.SETTINGS_GAMES_TOGGLE_OVERLAY", replacement: { match: /var .=(?.)\.overlay.+?"aria-label":.\..\.Messages\.SETTINGS_GAMES_TOGGLE_OVERLAY.+?}}\)/, - replace: "$&,Vencord.Plugins.plugins.IgnoreActivities.renderToggleGameActivityButton($)" + replace: "$&,$self.renderToggleGameActivityButton($)" } }, { find: ".overlayBadge", replacement: { match: /.badgeContainer.+?.\?\(0,.\.jsx\)\(.{1,2},{name:(?.)\.name}\):null/, - replace: "$&,Vencord.Plugins.plugins.IgnoreActivities.renderToggleActivityButton($)" + replace: "$&,$self.renderToggleActivityButton($)" } }, { find: '.displayName="LocalActivityStore"', replacement: { match: /(?.)\.push\(.\({type:.\..{1,3}\.LISTENING.+?\)\)/, - replace: "$&;$=$.filter(Vencord.Plugins.plugins.IgnoreActivities.isActivityNotIgnored);" + replace: "$&;$=$.filter($self.isActivityNotIgnored);" } }], diff --git a/src/plugins/loadingQuotes.ts b/src/plugins/loadingQuotes.ts index 052bfe6ec..7be6f3054 100644 --- a/src/plugins/loadingQuotes.ts +++ b/src/plugins/loadingQuotes.ts @@ -68,7 +68,7 @@ export default definePlugin({ find: ".LOADING_DID_YOU_KNOW", replacement: { match: /\._loadingText=.+?random\(.+?;/s, - replace: "._loadingText=Vencord.Plugins.plugins.LoadingQuotes.quote;", + replace: "._loadingText=$self.quote;", }, }, ], diff --git a/src/plugins/memberCount.tsx b/src/plugins/memberCount.tsx index 947d4d7b7..e17157e75 100644 --- a/src/plugins/memberCount.tsx +++ b/src/plugins/memberCount.tsx @@ -99,7 +99,7 @@ export default definePlugin({ find: ".isSidebarVisible,", replacement: { match: /(var (.)=.\.className.+?children):\[(.\.useMemo[^}]+"aria-multiselectable")/, - replace: "$1:[$2.startsWith('members')?Vencord.Plugins.plugins.MemberCount.render():null,$3" + replace: "$1:[$2.startsWith('members')?$self.render():null,$3" } }], diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index ff4c328c1..9242ce2f8 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -151,7 +151,7 @@ export default definePlugin({ replace: "MESSAGE_DELETE:function($1){" + " var cache = $2getOrCreate($1.channelId);" + - " cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, false);" + + " cache = $self.handleDelete(cache, $1, false);" + " $2commit(cache);" + "}," }, @@ -161,7 +161,7 @@ export default definePlugin({ replace: "MESSAGE_DELETE_BULK:function($1){" + " var cache = $2getOrCreate($1.channelId);" + - " cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, true);" + + " cache = $self.handleDelete(cache, $1, true);" + " $2commit(cache);" + "}," }, @@ -171,7 +171,7 @@ export default definePlugin({ replace: "$1" + ".update($3,m =>" + " $2.message.content !== m.editHistory?.[0]?.content && $2.message.content !== m.content ?" + - " m.set('editHistory',[...(m.editHistory || []), Vencord.Plugins.plugins.MessageLogger.makeEdit($2.message, m)]) :" + + " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($2.message, m)]) :" + " m" + ")" + ".update($3" @@ -287,7 +287,7 @@ export default definePlugin({ { // Render editHistory in the deepest div for message content match: /(\)\("div",\{id:.+?children:\[)/, - replace: "$1 (arguments[0].message.editHistory.length > 0 ? arguments[0].message.editHistory.map(edit => Vencord.Plugins.plugins.MessageLogger.renderEdit(edit)) : null), " + replace: "$1 (arguments[0].message.editHistory.length > 0 ? arguments[0].message.editHistory.map(edit => $self.renderEdit(edit)) : null), " } ] }, diff --git a/src/plugins/noBlockedMessages.ts b/src/plugins/noBlockedMessages.ts index bd72ce5fb..6937041a8 100644 --- a/src/plugins/noBlockedMessages.ts +++ b/src/plugins/noBlockedMessages.ts @@ -43,7 +43,7 @@ export default definePlugin({ replacement: [ { match: /(?<=MESSAGE_CREATE:function\((\w)\){var \w=\w\.channelId,\w=\w\.message,\w=\w\.isPushNotification,\w=\w\.\w\.getOrCreate\(\w\));/, - replace: ";if(Vencord.Plugins.plugins.NoBlockedMessages.isBlocked(n))return;" + replace: ";if($self.isBlocked(n))return;" } ] } diff --git a/src/plugins/noReplyMention.tsx b/src/plugins/noReplyMention.tsx index 91a88d308..2e9758893 100644 --- a/src/plugins/noReplyMention.tsx +++ b/src/plugins/noReplyMention.tsx @@ -51,7 +51,7 @@ export default definePlugin({ replacement: { match: /CREATE_PENDING_REPLY:function\((.{1,2})\){/, replace: - "CREATE_PENDING_REPLY:function($1){$1.shouldMention=Vencord.Plugins.plugins.NoReplyMention.shouldMention($1);", + "CREATE_PENDING_REPLY:function($1){$1.shouldMention=$self.shouldMention($1);", }, }, ], diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index c8481105d..7ebe91921 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -38,7 +38,7 @@ export default definePlugin({ find: "showCommunicationDisabledStyles", replacement: { match: /(?<=return\s*\(0,\w{1,3}\.jsxs?\)\(.+!\w{1,3}&&)(\(0,\w{1,3}.jsxs?\)\(.+?\{.+?\}\))/, - replace: "[$1, Vencord.Plugins.plugins.PronounDB.PronounsChatComponent(e)]" + replace: "[$1, $self.PronounsChatComponent(e)]" } }, // Hijack the discord pronouns section (hidden without experiment) and add a wrapper around the text section @@ -46,7 +46,7 @@ export default definePlugin({ find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", replacement: { match: /\(0,.\.jsx\)\((?.{1,2}\..),(?{currentPronouns.+?:(?.{1,2})\.pronouns.+?})\)/, - replace: "$&&Vencord.Plugins.plugins.PronounDB.PronounsProfileWrapper($,$,$)" + replace: "$&&$self.PronounsProfileWrapper($,$,$)" } }, // Make pronouns experiment be enabled by default diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 744c2d620..8e8398344 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -37,7 +37,7 @@ export default definePlugin({ find: "disableBorderColor:!0", replacement: { match: /\(.{0,10}\{user:(.),setNote:.,canDM:.,.+?\}\)/, - replace: "$&,Vencord.Plugins.plugins.ReviewDB.getReviewsComponent($1)" + replace: "$&,$self.getReviewsComponent($1)" }, } ], diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx index 86e187e31..5d82998df 100644 --- a/src/plugins/spotifyControls/index.tsx +++ b/src/plugins/spotifyControls/index.tsx @@ -55,7 +55,7 @@ export default definePlugin({ // return React.createElement(AccountPanel, { ..., showTaglessAccountPanel: blah }) match: /return ?(.{0,30}\(.{1,3},\{[^}]+?,showTaglessAccountPanel:.+?\}\))/, // return [Player, Panel] - replace: "return [Vencord.Plugins.plugins.SpotifyControls.renderPlayer(),$1]" + replace: "return [$self.renderPlayer(),$1]" } }, // Adds POST and a Marker to the SpotifyAPI (so we can easily find it) diff --git a/src/plugins/startupTimings/index.tsx b/src/plugins/startupTimings/index.tsx index 2ab00a646..5d66f5ffc 100644 --- a/src/plugins/startupTimings/index.tsx +++ b/src/plugins/startupTimings/index.tsx @@ -29,7 +29,7 @@ export default definePlugin({ find: "PAYMENT_FLOW_MODAL_TEST_PAGE,", replacement: { match: /{section:.{1,2}\..{1,3}\.PAYMENT_FLOW_MODAL_TEST_PAGE/, - replace: '{section:"StartupTimings",label:"Startup Timings",element:Vencord.Plugins.plugins.StartupTimings.StartupTimingPage},$&' + replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&' } }], StartupTimingPage: LazyComponent(() => require("./StartupTimingPage").default) diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index 1985107c3..39b8a059c 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -42,7 +42,7 @@ export default definePlugin({ // voice/stage channels { match: /onClick:function\(\)\{(e\.handleClick.+?)}/g, - replace: "onClick:function(){Vencord.Plugins.plugins.VoiceChatDoubleClick.schedule(()=>{$1},e)}", + replace: "onClick:function(){$self.schedule(()=>{$1},e)}", }, ], }, diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx index 307fd0154..26f29029d 100644 --- a/src/plugins/viewIcons.tsx +++ b/src/plugins/viewIcons.tsx @@ -79,7 +79,7 @@ export default new class ViewIcons implements PluginDef { }, { match: /(id:"leave-guild".{0,200}),(\(0,.{1,3}\.jsxs?\).{0,200}function)/, - replace: "$1,Vencord.Plugins.plugins.ViewIcons.buildGuildContextMenuEntries(_guild),$2" + replace: "$1,$self.buildGuildContextMenuEntries(_guild),$2" } ] } diff --git a/src/plugins/whoReacted.tsx b/src/plugins/whoReacted.tsx index 685d95421..a14ca3a2a 100644 --- a/src/plugins/whoReacted.tsx +++ b/src/plugins/whoReacted.tsx @@ -92,7 +92,7 @@ export default definePlugin({ find: ",reactionRef:", replacement: { match: /((.)=(.{1,3})\.hideCount)(,.+?reactionCount.+?\}\))/, - replace: "$1,whoReactedProps=$3$4,$2?null:Vencord.Plugins.plugins.WhoReacted.renderUsers(whoReactedProps)" + replace: "$1,whoReactedProps=$3$4,$2?null:$self.renderUsers(whoReactedProps)" } }],