mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-06-16 04:51:16 +00:00
27 lines
No EOL
597 B
JavaScript
27 lines
No EOL
597 B
JavaScript
import emojis from "emojibase-data/en/compact.json";
|
|
import {
|
|
groups
|
|
} from "emojibase-data/meta/groups.json";
|
|
|
|
export default message => {
|
|
const regex = /:([\w]+):/g;
|
|
|
|
return message.replace(regex, (x) => {
|
|
const emoji = emojiExists(x.replace(/[::]+/g, ''))
|
|
|
|
if (emoji) return emoji.unicode
|
|
return x
|
|
});
|
|
};
|
|
|
|
function emojiExists(shortCode) {
|
|
for (let index = 0; index < emojis.length; index++) {
|
|
const element = emojis[index];
|
|
for (let i = 0; i < element.shortcodes.length; i++) {
|
|
const el2 = element.shortcodes[i];
|
|
if (el2 === shortCode) {
|
|
return element
|
|
}
|
|
}
|
|
}
|
|
} |