1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-11 02:16:23 +00:00

Use helper function in replacement

This commit is contained in:
Grzesiek11 2024-02-18 03:21:46 +01:00
parent 8cd00a3c05
commit a4d91fb739
No known key found for this signature in database
GPG key ID: 4A5445FB68CDB5C4

View file

@ -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;