Skip to content

Commit d0fcd4e

Browse files
committed
this might be pretty sick
1 parent 5220917 commit d0fcd4e

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

‎plugins/BetterCode/src/index.ts‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// BetterCode plugin - Fixed version with correct Vendetta patcher usage
22
import { storage } from "@vendetta/plugin";
3-
import { before, instead } from "@vendetta/patcher";
3+
import { instead } from "@vendetta/patcher";
44
import { ReactNative } from "@vendetta/metro/common";
55
import { findByProps } from "@vendetta/metro";
66
import 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
);

‎plugins/BetterCode/vendetta.d.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ declare module "@vendetta/plugin" {
55

66
declare module "@vendetta/patcher" {
77
export function before<T extends unknown[]>(
8-
obj: unknown,
9-
method: string,
10-
cb: (...args: T) => void
8+
func: string,
9+
parent: any,
10+
cb: (args: T, ret?: any) => void | unknown | unknown[]
1111
): () => void;
1212

1313
export function after<T extends unknown[]>(
14-
obj: unknown,
15-
method: string,
16-
cb: (...args: T) => void
14+
func: string,
15+
parent: any,
16+
cb: (args: T, ret: any) => void | unknown | unknown[]
1717
): () => void;
1818

1919
export function instead<T extends unknown[]>(
20-
obj: unknown,
21-
method: string,
22-
cb: (...args: T) => void
20+
func: string,
21+
parent: any,
22+
cb: (args: T, origFunc: Function) => void | unknown | unknown[]
2323
): () => void;
2424
}
2525

0 commit comments

Comments
 (0)