diff --git a/commands/message/fun/emojimix.js b/commands/message/fun/emojimix.js new file mode 100644 index 0000000..dc49636 --- /dev/null +++ b/commands/message/fun/emojimix.js @@ -0,0 +1,65 @@ +const { Constants } = require("detritus-client"); +const Permissions = Constants.Permissions; + +const { createEmbed } = require('../../../labscore/utils/embed') +const { editOrReply } = require('../../../labscore/utils/message') + +const { emojiKitchen } = require('../../../labscore/api') + +const onlyEmoji = require('emoji-aware').onlyEmoji; + +module.exports = { + label: "emoji", + name: "emoji", + aliases: ["em"], + metadata: { + description: 'mix two emoji', + examples: ['emoji 🐱🍞'], + category: 'fun', + usage: 'emoji ' + }, + ratelimit: { + type: 'guild', + limit: 1, + duration: 2000 + }, + permissionsClient: [Permissions.EMBED_LINKS], + run: async (context, args) => { + await context.triggerTyping(); + + const emojis = onlyEmoji(args.emoji) + + if(emojis.length <= 1) return editOrReply(context, createEmbed("warning", context, "You need at least two emoji to mix.")) + + try{ + let em = await emojiKitchen(emojis) + if(!em.body.results[0]){ + try{ + await emojiKitchen([emojis[0]]) + }catch(e){ + return editOrReply(context, createEmbed("error", context, `Invalid Emoji (${emojis[0]})`)) + } + try{ + await emojiKitchen([emojis[1]]) + }catch(e){ + return editOrReply(context, createEmbed("error", context, `Invalid Emoji (${emojis[1]})`)) + } + return editOrReply(context, createEmbed("error", context, "Combination not supported")) + } + return editOrReply(context, createEmbed("image", context, { url: em.body.results[0].url })) + + }catch(e){ + console.log(e) + return context.editOrReply({ + embed: { + author: { + iconUrl: context.message.author.avatarUrl, + name: `${context.message.author.username}#${context.message.author.discriminator}` + }, + color: Colors.error, + description: `${Icons.error} You need two emoji to mix.`, + } + }) + } + } +}; \ No newline at end of file diff --git a/labscore/api/index.js b/labscore/api/index.js index 082b192..145a7e8 100644 --- a/labscore/api/index.js +++ b/labscore/api/index.js @@ -265,4 +265,15 @@ module.exports.screenshot = async function(context, url, nsfw){ module.exports.emojiTwitter = async function(codepoint){ return Static.HOST + Static.TWITTER(codepoint) +} + +module.exports.emojiKitchen = async function(emoji){ + return await superagent.get("https://tenor.googleapis.com/v2/featured").query({ + key: process.env.GOOGLE_TENOR_KEY, + contentfilter: "high", + media_filter: "png_transparent", + component: "proactive", + collection: "emoji_kitchen_v5", + q: emoji.join('_') + }) } \ No newline at end of file