UNPKG

emoxy

Version:
235 lines (234 loc) 5.05 kB
/** * name: emoxy * version: v1.0.2 * description: A wrapper for emojihub api * author: COD3VIL * homepage: https://mykenji.vercel.app/projects/emoxy */ var m = Object.defineProperty; var u = (a, e, o) => e in a ? m(a, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : a[e] = o; var c = (a, e, o) => (u(a, typeof e != "symbol" ? e + "" : e, o), o); class i { constructor() { /** * @description Emojihub api URL * @private * @memberof Emoxy */ c(this, "BASE_URL", "https://emojihub.yurace.pro/api"); } /** * @description Gets all emojis * @return {*} {Promise<EmoxyResponseGroup>} * @memberof Emoxy */ async all_emojis() { const e = `${this.BASE_URL}/all`; try { return { code: 200, message: "Success", emojis: await (await fetch(e)).json() }; } catch (o) { return { code: 500, message: `${o}`, emojis: null }; } } /** * @description Returns a random emoji from a given category * @param {EmoxyEmojiCategory} category * @return {*} {Promise<EmoxyResponse>} * @memberof Emoxy */ async random_emoji_cat(e) { const o = `${this.BASE_URL}/random/category/${e}`; try { return { code: 200, message: "Success", emoji: await (await fetch(o)).json() }; } catch { return { code: 500, message: "Fetch Error: failed to fetch", emoji: null }; } } /** * @description Gets all emojis from a given category * @param {EmoxyEmojiCategory} category * @return {*} {Promise<EmoxyResponseGroup>} * @memberof Emoxy */ async all_emoji_cat(e) { const o = `${this.BASE_URL}/all/category/${e}`; try { return { code: 200, message: "Success", emojis: await (await fetch(o)).json() }; } catch { return { code: 500, message: "Fetch Error: failed to fetch", emojis: null }; } } /** * @description Gets a random emoji from a given group * @param {string} group * @return {*} {Promise<EmoxyResponse>} * @memberof Emoxy */ async random_emoji_group(e) { const o = `${this.BASE_URL}/random/group/${e}`; try { return { code: 200, message: "Success", emoji: await (await fetch(o)).json() }; } catch { return { code: 500, message: "Fetch Error: failed to fetch", emoji: null }; } } /** * @description Gets all emojis from a given group * @param {string} group * @return {*} {Promise<EmoxyResponseGroup>} * @memberof Emoxy */ async all_emoji_group(e) { const o = `${this.BASE_URL}/all/group/${e}`; try { return { code: 200, message: "Success", emojis: await (await fetch(o)).json() }; } catch { return { code: 500, message: "Fetch Error: failed to fetch", emojis: null }; } } } const d = new i(); async function g() { return await d.all_emojis(); } const s = new i(); async function f(a = "smileys-and-people") { const e = await s.random_emoji_cat(a); return e === null ? null : e; } async function j(a = "smileys-and-people") { const e = await s.all_emoji_cat(a); return e === null ? null : e; } async function y(a = "emotion") { const e = await s.random_emoji_group(a); return e === null ? null : e; } async function h(a = "emotion") { const e = await s.all_emoji_group(a); return e === null ? null : e; } const l = [ { name: "smileys-and-people", group: [ "body", "cat-face", "clothing", "creature-face", "emotion", "face-negative", "face-neutral", "face-positive", "face-role", "face-sick", "family", "monkey-face", "person", "person-activity", "person-gesture", "person-role", "skin-tone" ] }, { name: "animals-and-nature", group: [ "animal-amphibian", "animal-bird", "animal-bug", "animal-mammal", "animal-marine", "animal-reptile", "plant-flower", "plant-other" ] }, { name: "food-and-drink", group: [ "dishware", "drink", "food-asian", "food-fruit", "food-prepared", "food-sweet", "food-vegetable" ] }, { name: "travel-and-places", group: ["travel-and-places"] }, { name: "activities", group: ["activities"] }, { name: "objects", group: ["objects"] }, { name: "symbols", group: ["symbols"] }, { name: "flags", group: ["flags"] } ]; function _() { return l.map((a) => a.name); } function w(a) { return l.filter((e) => e.name === a).map((e) => e.group)[0]; } export { _ as getAllCategories, g as getAllEmojis, j as getAllEmojisInCategory, h as getAllEmojisInGroup, f as getRandomEmojiInCategory, y as getRandomEmojiInGroup, w as getSpecificGroups };