diff options
author | hunter <61890674+hunt-g@users.noreply.github.com> | 2023-03-24 20:54:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-25 03:54:20 +0100 |
commit | 93cb51a975ce457d6091dc7b0230610f3b958bef (patch) | |
tree | 6cc945469e5d0126e8121aadd362dd98d63d27b6 /src/plugins/apiMessageEvents.ts | |
parent | 0b4ae729a3fecf017583fb968b11ab46e584e0ce (diff) | |
download | Vencord-93cb51a975ce457d6091dc7b0230610f3b958bef.tar.gz Vencord-93cb51a975ce457d6091dc7b0230610f3b958bef.tar.bz2 Vencord-93cb51a975ce457d6091dc7b0230610f3b958bef.zip |
feat(MessageEvents): Promisable send/edit listeners (#514)
* promisable send/edit listeners
* added self
* Apply suggestions from code review
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
* fix patches
---------
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/apiMessageEvents.ts')
-rw-r--r-- | src/plugins/apiMessageEvents.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/apiMessageEvents.ts b/src/plugins/apiMessageEvents.ts index 13fbc4c..6843200 100644 --- a/src/plugins/apiMessageEvents.ts +++ b/src/plugins/apiMessageEvents.ts @@ -22,22 +22,22 @@ import definePlugin from "@utils/types"; export default definePlugin({ name: "MessageEventsAPI", description: "Api required by anything using message events.", - authors: [Devs.Arjix], + authors: [Devs.Arjix, Devs.hunt], patches: [ { - find: "sendMessage:function", + find: '"MessageActionCreators"', replacement: [{ - match: /(?<=_sendMessage:function\([^)]+\)){/, - replace: "{if(Vencord.Api.MessageEvents._handlePreSend(...arguments)){return;};" + match: /_sendMessage:(function\([^)]+\)){/, + replace: "_sendMessage:async $1{if(await Vencord.Api.MessageEvents._handlePreSend(...arguments))return;" }, { - match: /(?<=\beditMessage:function\([^)]+\)){/, - replace: "{Vencord.Api.MessageEvents._handlePreEdit(...arguments);" + match: /\beditMessage:(function\([^)]+\)){/, + replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);" }] }, { find: '("interactionUsernameProfile', replacement: { - match: /var \w=(\w)\.id,\w=(\w)\.id;return .{1,2}\.useCallback\(\(?function\((.{1,2})\){/, + match: /var \i=(\i)\.id,\i=(\i)\.id;return \i\.useCallback\(\(?function\((\i)\){/, replace: (m, message, channel, event) => // the message param is shadowed by the event param, so need to alias them `var _msg=${message},_chan=${channel};${m}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});` |