11// BetterCode plugin - Fixed version with correct Vendetta patcher usage
22import { storage } from "@vendetta/plugin" ;
3- import { before , instead } from "@vendetta/patcher" ;
3+ import { instead } from "@vendetta/patcher" ;
44import { ReactNative } from "@vendetta/metro/common" ;
55import { findByProps } from "@vendetta/metro" ;
66import Prism from "prismjs" ;
@@ -231,24 +231,24 @@ export default {
231231 }
232232
233233 console . log ( "[BetterCode] DCDChatManager found" ) ;
234- console . log ( "[BetterCode] updateRows:" , DCDChatManager . updateRows ) ;
235234
235+ // Use the correct signature: (funcName, parent, callback)
236236 unpatch = instead (
237- DCDChatManager ,
238- "updateRows" ,
239- ( ( ... args : unknown [ ] ) => {
240- console . log ( "[BetterCode] instead() callback called with args:" , args ) ;
237+ "updateRows" , // funcName - the method name as string
238+ DCDChatManager , // parent - the parent object
239+ ( ( args : unknown [ ] , origFunc : Function ) => {
240+ console . log ( "[BetterCode] instead() called with args:" , args ) ;
241241
242242 if ( args . length < 2 || typeof args [ 1 ] !== "string" ) {
243243 console . warn ( "[BetterCode] args[1] not string, passing through" ) ;
244- return args ; // Pass through original args
244+ return ;
245245 }
246246
247247 try {
248248 const rows = JSON . parse ( args [ 1 ] ) ;
249249 if ( ! Array . isArray ( rows ) ) {
250250 console . warn ( "[BetterCode] rows is not an array" ) ;
251- return args ;
251+ return ;
252252 }
253253
254254 for ( const row of rows ) {
@@ -264,11 +264,9 @@ export default {
264264 }
265265
266266 args [ 1 ] = JSON . stringify ( rows ) ;
267- console . log ( "[BetterCode] Successfully processed rows with instead()" ) ;
268- return args ;
267+ console . log ( "[BetterCode] Successfully processed rows" ) ;
269268 } catch ( e ) {
270269 console . error ( "[BetterCode] Processing error:" , e ) ;
271- return args ;
272270 }
273271 } ) as any
274272 ) ;
0 commit comments