emoxy
Version:
A wrapper for emojihub api
9 lines (8 loc) • 3.21 kB
JavaScript
/**
* name: emoxy
* version: v1.0.2
* description: A wrapper for emojihub api
* author: COD3VIL
* homepage: https://mykenji.vercel.app/projects/emoxy
*/
(function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.Emoxy={}))})(this,function(a){"use strict";var _=Object.defineProperty;var E=(a,o,r)=>o in a?_(a,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[o]=r;var u=(a,o,r)=>(E(a,typeof o!="symbol"?o+"":o,r),r);class o{constructor(){u(this,"BASE_URL","https://emojihub.yurace.pro/api")}async all_emojis(){const e=`${this.BASE_URL}/all`;try{return{code:200,message:"Success",emojis:await(await fetch(e)).json()}}catch(n){return{code:500,message:`${n}`,emojis:null}}}async random_emoji_cat(e){const n=`${this.BASE_URL}/random/category/${e}`;try{return{code:200,message:"Success",emoji:await(await fetch(n)).json()}}catch{return{code:500,message:"Fetch Error: failed to fetch",emoji:null}}}async all_emoji_cat(e){const n=`${this.BASE_URL}/all/category/${e}`;try{return{code:200,message:"Success",emojis:await(await fetch(n)).json()}}catch{return{code:500,message:"Fetch Error: failed to fetch",emojis:null}}}async random_emoji_group(e){const n=`${this.BASE_URL}/random/group/${e}`;try{return{code:200,message:"Success",emoji:await(await fetch(n)).json()}}catch{return{code:500,message:"Fetch Error: failed to fetch",emoji:null}}}async all_emoji_group(e){const n=`${this.BASE_URL}/all/group/${e}`;try{return{code:200,message:"Success",emojis:await(await fetch(n)).json()}}catch{return{code:500,message:"Fetch Error: failed to fetch",emojis:null}}}}const r=new o;async function d(){return await r.all_emojis()}const i=new o;async function p(t="smileys-and-people"){const e=await i.random_emoji_cat(t);return e===null?null:e}async function g(t="smileys-and-people"){const e=await i.all_emoji_cat(t);return e===null?null:e}async function f(t="emotion"){const e=await i.random_emoji_group(t);return e===null?null:e}async function j(t="emotion"){const e=await i.all_emoji_group(t);return e===null?null:e}const m=[{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 y(){return m.map(t=>t.name)}function h(t){return m.filter(e=>e.name===t).map(e=>e.group)[0]}a.getAllCategories=y,a.getAllEmojis=d,a.getAllEmojisInCategory=g,a.getAllEmojisInGroup=j,a.getRandomEmojiInCategory=p,a.getRandomEmojiInGroup=f,a.getSpecificGroups=h,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});