diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index 739c7b8ec..6d1bc85d2 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -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};" }