11import { instead , before , after } from "@vendetta/patcher"
22import { getAssetIDByName } from "@vendetta/ui/assets"
33import { findInReactTree } from "@vendetta/utils"
4- import { findByProps } from "@vendetta/metro"
4+ import { findByProps , findByStoreName } from "@vendetta/metro"
55import { React , FluxDispatcher } from "@vendetta/metro/common"
66import { Forms } from "@vendetta/ui/components"
77import { storage } from "@vendetta/plugin" ;
@@ -11,12 +11,28 @@ const ChannelStore = findByProps("getChannel", "getDMFromUserId");
1111const ChannelMessages = findByProps ( "_channelMessages" ) ;
1212const MessageStore = findByProps ( 'getMessage' , 'getMessages' ) ;
1313
14+ /* THIS Function Janky
15+ const altMessageStore = findByStoreName("MessageStore")
16+ const logs = altMessageStore._dispatcher.actionLogger.logs;
17+
18+ function messageGetter(authorId) {
19+ const allOcc = logs.filter(x =>
20+ x?.action?.type === "MESSAGE_UPDATE" &&
21+ x?.action?.message?.author?.id === authorId
22+ );
23+
24+ // Use .at(-1) for cleaner syntax, with a fallback to the old way
25+ const lastEntry = allOcc.at(-1);
26+ return lastEntry?.action?.message ?? null;
27+ }
28+
29+ */
1430
1531/*
16- This forsaken File, ohhh maa gaaawd
32+ i kinda hated discord constant nugging the flux
1733
1834
19- - Angelica
35+ - Angelw0lf
2036*/
2137
2238export default ( deletedMessageArray ) => before ( "dispatch" , FluxDispatcher , ( args ) => {
@@ -94,26 +110,40 @@ export default (deletedMessageArray) => before("dispatch", FluxDispatcher, (args
94110
95111 // Message Update Patch
96112 if ( type == "MESSAGE_UPDATE" ) {
113+ // console.log(event)
97114 if ( storage . switches . enableMU == false ) return args ;
98115
99116 if ( event ?. otherPluginBypass ) return args ;
100117
101118 if ( event ?. message ?. author ?. bot ) return args ;
102119
103- const originalMessage = MessageStore . getMessage (
104- ( event ?. message ?. channel_id || event ?. channelId ) ,
105- ( event ?. message ?. id || event ?. id )
106- ) ;
120+ const channelId = event ?. message ?. channel_id ?? event ?. channelId ;
121+ const messageId = event ?. message ?. id ?? event ?. id ;
122+
123+ let originalMessage = null ;
124+
125+ // first use existing getter;
126+ if ( channelId && messageId ) {
127+ originalMessage = MessageStore . getMessage ( channelId , messageId ) ;
128+
129+ if ( ! originalMessage ) {
130+ const channel = ChannelMessages . get ( channelId ) ;
131+ originalMessage = channel ?. get ( messageId ) ;
132+ }
133+ }
134+
135+ // console.log(event?.message?.content)
136+ // console.log(originalMessage?.content)
137+
138+ // if still doesnt exist then just bypass
139+ if ( ! originalMessage ) return args ;
107140
108- const OMCheck1 = originalMessage ?. author ?. id ;
109- const OMCheck2 = originalMessage ?. author ?. username ;
110- const OMCheck3 = ( ! originalMessage ?. content && originalMessage ?. attachments ?. length == 0 && originalMessage ?. embeds ?. length == 0 ) ;
111-
112- if ( ! originalMessage || ! OMCheck1 || ! OMCheck2 || OMCheck3 ) return args ;
141+ if ( ! originalMessage . author ?. id || ! originalMessage . author ?. username ) return args ;
142+ if ( ! originalMessage . content && originalMessage . attachments ?. length === 0 && originalMessage . embeds ?. length === 0 ) return args ;
113143
114- if ( ! event ?. message ?. content || ! originalMessage ?. content ) return args ;
144+ if ( ! event ?. message ?. content ) return args ;
115145
116- if ( event ?. message ?. content == originalMessage ?. content ) return args ;
146+ if ( event ?. message ?. content == originalMessage ?. content ) return args ;
117147
118148 if (
119149 ( storage ?. inputs ?. ignoredUserList ?. length > 0 ) &&
0 commit comments