Fixed config checker emoji count

This commit is contained in:
DJj123dj
2024-09-01 21:30:56 +02:00
parent c1c80fc04d
commit 504889a83d
+7 -9
View File
@@ -1194,18 +1194,16 @@ export class ODCheckerCustomStructure_EmojiString extends ODCheckerStringStructu
const lt = checker.locationTraceDeref(locationTrace) const lt = checker.locationTraceDeref(locationTrace)
if (typeof value != "string") return false if (typeof value != "string") return false
const emojis: string[] = [] const discordEmojiSplitter = /(?:<a?:[^:]*:[0-9]+>)/g
const emojiSplitRegex = /(?:(?:\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])|(?:<a?:[^:]*:[0-9]+>))/g const splitted = value.split(discordEmojiSplitter)
let emoji = emojiSplitRegex.exec(value) const discordEmojiAmount = splitted.length-1
while (emoji != null){ const unicodeEmojiAmount = [...new Intl.Segmenter().segment(splitted.join(""))].length
emojis.push(emoji[0]) const emojiAmount = discordEmojiAmount+unicodeEmojiAmount
emoji = emojiSplitRegex.exec(value)
}
if (emojis.length < minLength){ if (emojiAmount < minLength){
checker.createMessage("openticket:emoji-too-short","error",`This string needs to have at least ${minLength} emoji's!`,lt,null,[maxLength.toString()],this.id,(this.options.docs ?? null)) checker.createMessage("openticket:emoji-too-short","error",`This string needs to have at least ${minLength} emoji's!`,lt,null,[maxLength.toString()],this.id,(this.options.docs ?? null))
return false return false
}else if (emojis.length > maxLength){ }else if (emojiAmount > maxLength){
checker.createMessage("openticket:emoji-too-long","error",`This string needs to have at most ${maxLength} emoji's!`,lt,null,[maxLength.toString()],this.id,(this.options.docs ?? null)) checker.createMessage("openticket:emoji-too-long","error",`This string needs to have at most ${maxLength} emoji's!`,lt,null,[maxLength.toString()],this.id,(this.options.docs ?? null))
return false return false
}else if (!allowCustomDiscordEmoji && /<a?:[^:]*:[0-9]+>/.test(value)){ }else if (!allowCustomDiscordEmoji && /<a?:[^:]*:[0-9]+>/.test(value)){