fix plugins that modify text (FakeNitro, TextReplace)

This commit is contained in:
Vendicated 2026-08-27 17:31:50 +02:00
parent bff6b594c7
commit bc680139be
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -37,9 +37,9 @@ export default definePlugin({
{
find: ".handleSendMessage,onResize:",
replacement: {
// https://regex101.com/r/7iswuk/1
match: /let (\i)=\i\.\i\.parse\((\i),.+?\.getSendMessageOptions\(\{.+?\}\)?;(?=.+?(\i)\.flags=)(?<=\)\(({.+?})\)\.then.+?)/,
replace: (m, parsedMessage, channel, options, props) => m +
// TODO: simplify once Discord decides on if this .then() callback should be async or not
match: /(?<=channel:\i\}\)\.then\()(?:async )?(\i=>.+?let (\i)=\i\.\i\.parse\((\i),.+?\.getSendMessageOptions\(\{.+?\}\)?;)(?=.+?(\i)\.flags=)(?<=\)\(({.+?})\)\.then.+?)/,
replace: (m, restCode, parsedMessage, channel, options, props) => "async " + restCode +
`if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${options},${props}))` +
"return{shouldClear:false,shouldRefocus:true};"
}