blob: bbc8f246ba2325371cce80aae12129775546469c [file] [log] [blame]
pineafan4f164f32022-02-26 22:07:12 +00001import emojis from '../config/emojis.json' assert {type: 'json'};
2
pineafan8b4b17f2022-02-27 20:42:52 +00003function getEmojiByName(name: string, format?: string): string {
pineafan4f164f32022-02-26 22:07:12 +00004 let split = name.split(".");
5 let id = emojis
6 split.forEach(part => {
7 id = id[part];
8 });
pineafan8b4b17f2022-02-27 20:42:52 +00009 if ( format === "id" ) {
10 if (id === undefined) return "0";
11 return id.toString();
12 }
13 if (id === undefined) {
14 return `<a:a:946346549271732234>`
15 } else if (id.toString().startsWith("a")) {
pineafan1dc15722022-03-14 21:27:34 +000016 return `<a:a:${id.toString().slice(1, id.toString().length)}>`
pineafan8b4b17f2022-02-27 20:42:52 +000017 }
pineafan4f164f32022-02-26 22:07:12 +000018 return `<:a:${id}>`;
19}
20
21export default getEmojiByName;