Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions core/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ declare function ScanResourceRoot(rootPath: string, callback: (data: object) =>
declare function VerifyPasswordHash(password: string, hash: string): boolean;


/**
* MARK: Fixes
*/
declare module 'unicode-emoji-json/data-ordered-emoji' {
const emojis: string[];
export = emojis;
}

//FIXME: checar se eu preciso disso
// interface ProcessEnv {
// [x: string]: string | undefined;
Expand Down
5 changes: 2 additions & 3 deletions core/modules/DiscordBot/discordHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const modulename = 'DiscordBot:cmd';
import orderedEmojis from 'unicode-emoji-json/data-ordered-emoji';
import { ColorResolvable, CommandInteraction, EmbedBuilder, InteractionReplyOptions } from "discord.js";
import consoleFactory from '@lib/console';
const console = consoleFactory(modulename);
const allEmojis = new Set(orderedEmojis);
const emojiRegex = /^\p{RGI_Emoji}$/v;



Expand Down Expand Up @@ -96,7 +95,7 @@ export const isValidButtonEmoji = (emoji: unknown) => {
if (typeof emoji !== 'string') return false;
if (/^\d{17,19}$/.test(emoji)) return true;
if (/^<a?:\w{2,32}:\d{17,19}>$/.test(emoji)) return true;
return allEmojis.has(emoji);
return emojiRegex.test(emoji);
}


Expand Down
1 change: 0 additions & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"string-argv": "^0.3.2",
"systeminformation": "^5.23.5",
"throttle-debounce": "^5.0.2",
"unicode-emoji-json": "^0.8.0",
"xss": "^1.0.15",
"zod": "^3.23.8",
"zod-validation-error": "^3.4.0"
Expand Down
7 changes: 0 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 4 additions & 21 deletions shared/cleanPlayerName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,11 @@ const hexInvalidString = (str: string, limit = 35) => {


/**
* Checks if a character is an emoji.
* TODO: this is not perfect, use @mathiasbynens/emoji-regex
* or await for NodeJS 20 and use the native regex /^\p{RGI_Emoji}$/v
* ref: https://v8.dev/features/regexp-v-flag
* NOTE: also remove the library unicode-emoji-json, being used by the discord bot
* Checks if a character is an emoji using the native RGI_Emoji property.
* ref: https://v8.dev/features/regexp-v-flag
*/
const isEmoji = (char: string) => {
const codePoint = char.codePointAt(0)!;
return (
(codePoint >= 0x1F300 && codePoint <= 0x1F5FF) || // Miscellaneous Symbols and Pictographs
(codePoint >= 0x1F600 && codePoint <= 0x1F64F) || // Emoticons
(codePoint >= 0x1F680 && codePoint <= 0x1F6FF) || // Transport and Map Symbols
(codePoint >= 0x1F700 && codePoint <= 0x1F77F) || // Alchemical Symbols
(codePoint >= 0x1F780 && codePoint <= 0x1F7FF) || // Geometric Shapes Extended
(codePoint >= 0x1F800 && codePoint <= 0x1F8FF) || // Supplemental Arrows-C
(codePoint >= 0x1F900 && codePoint <= 0x1F9FF) || // Supplemental Symbols and Pictographs
(codePoint >= 0x1FA00 && codePoint <= 0x1FA6F) || // Chess Symbols
(codePoint >= 0x1FA70 && codePoint <= 0x1FAFF) || // Symbols and Pictographs Extended-A
(codePoint >= 0x2600 && codePoint <= 0x26FF) || // Miscellaneous Symbols
(codePoint >= 0x2700 && codePoint <= 0x27BF) // Dingbats
);
}
const emojiRegex = /^\p{RGI_Emoji}$/v;
const isEmoji = (char: string) => emojiRegex.test(char);


/**
Expand Down