From a4d91fb739b52165c39a2ea99ba18594d3cd6465 Mon Sep 17 00:00:00 2001 From: Grzesiek11 Date: Sun, 18 Feb 2024 03:21:46 +0100 Subject: [PATCH] Use helper function in replacement --- src/plugins/ircColors/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts index e92b16756..04a47ab93 100644 --- a/src/plugins/ircColors/index.ts +++ b/src/plugins/ircColors/index.ts @@ -28,12 +28,15 @@ export default definePlugin({ find: "=\"SYSTEM_TAG\"", replacement: { match: /(?<=className:\i\.username,style:.{0,50}:void 0,)/, - replace: "style:{color:$self.calculateNameColor(BigInt(arguments[0].message.author.id))}" + replace: "style:{color:$self.calculateNameColorForContext(arguments[0])}" }, }, ], // Calculate a CSS color string based on the user ID - calculateNameColor(id: bigint) { + calculateNameColorForContext(context: any) { + return this.calculateNameColorForUser(BigInt(context.message.author.id)); + }, + calculateNameColorForUser(id: bigint) { // Compute a 64-bit FNV-1a hash of the passed data function hash(data: ArrayBuffer) { const fnvPrime = 1099511628211n;