diff --git a/src/core/api/modules/checker.ts b/src/core/api/modules/checker.ts index 956867d..54df443 100644 --- a/src/core/api/modules/checker.ts +++ b/src/core/api/modules/checker.ts @@ -1194,18 +1194,16 @@ export class ODCheckerCustomStructure_EmojiString extends ODCheckerStringStructu const lt = checker.locationTraceDeref(locationTrace) if (typeof value != "string") return false - const emojis: string[] = [] - const emojiSplitRegex = /(?:(?:\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])|(?:))/g - let emoji = emojiSplitRegex.exec(value) - while (emoji != null){ - emojis.push(emoji[0]) - emoji = emojiSplitRegex.exec(value) - } - - if (emojis.length < minLength){ + const discordEmojiSplitter = /(?:)/g + const splitted = value.split(discordEmojiSplitter) + const discordEmojiAmount = splitted.length-1 + const unicodeEmojiAmount = [...new Intl.Segmenter().segment(splitted.join(""))].length + const emojiAmount = discordEmojiAmount+unicodeEmojiAmount + + 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)) 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)) return false }else if (!allowCustomDiscordEmoji && //.test(value)){