mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 23:23:08 -04:00
update emoji command
This commit is contained in:
parent
7a563b5fb8
commit
d9c1978d8c
2 changed files with 42 additions and 22 deletions
|
@ -3,11 +3,32 @@ const { emojipedia, emojiKitchen } = require("../../../labscore/api");
|
||||||
|
|
||||||
const { EMOJIPEDIA_PLATFORM_TYPES, EMOJIPEDIA_PLATFORM_TYPE_ALIASES } = require("../../../labscore/constants");
|
const { EMOJIPEDIA_PLATFORM_TYPES, EMOJIPEDIA_PLATFORM_TYPE_ALIASES } = require("../../../labscore/constants");
|
||||||
const { createEmbed } = require("../../../labscore/utils/embed");
|
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
|
const { citation } = require("../../../labscore/utils/markdown");
|
||||||
const { editOrReply } = require("../../../labscore/utils/message");
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
const { STATICS } = require("../../../labscore/utils/statics");
|
const { STATICS } = require("../../../labscore/utils/statics");
|
||||||
|
|
||||||
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
||||||
|
|
||||||
|
function toCodePoint(unicodeSurrogates, sep) {
|
||||||
|
var
|
||||||
|
r = [],
|
||||||
|
c = 0,
|
||||||
|
p = 0,
|
||||||
|
i = 0;
|
||||||
|
while (i < unicodeSurrogates.length) {
|
||||||
|
c = unicodeSurrogates.charCodeAt(i++);
|
||||||
|
if (p) {
|
||||||
|
r.push((0x10000 + ((p - 0xD800) << 10) + (c - 0xDC00)).toString(16));
|
||||||
|
p = 0;
|
||||||
|
} else if (0xD800 <= c && c <= 0xDBFF) {
|
||||||
|
p = c;
|
||||||
|
} else {
|
||||||
|
r.push(c.toString(16));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r.join(sep || '-');
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
label: "emoji",
|
label: "emoji",
|
||||||
name: "emoji",
|
name: "emoji",
|
||||||
|
@ -89,35 +110,33 @@ module.exports = {
|
||||||
// Regular Emoji Handling
|
// Regular Emoji Handling
|
||||||
if(emoji.length == 0) return await editOrReply(context, createEmbed("warning", context, "You need to specify an emoji to enlarge."))
|
if(emoji.length == 0) return await editOrReply(context, createEmbed("warning", context, "You need to specify an emoji to enlarge."))
|
||||||
|
|
||||||
if(!EMOJIPEDIA_PLATFORM_TYPES.includes(args.type.toLowerCase())){
|
if(!EMOJIPEDIA_PLATFORM_TYPES.includes(args.type.toLowerCase()) && EMOJIPEDIA_PLATFORM_TYPE_ALIASES[args.type.toLowerCase()]) args.type = EMOJIPEDIA_PLATFORM_TYPE_ALIASES[args.type.toLowerCase()]
|
||||||
if(!EMOJIPEDIA_PLATFORM_TYPE_ALIASES[args.type.toLowerCase()]) return await editOrReply(context, createEmbed("warning", context, "Invalid platform type (" + args.type.toLowerCase() + ")"))
|
|
||||||
args.type = EMOJIPEDIA_PLATFORM_TYPE_ALIASES[args.type.toLowerCase()]
|
|
||||||
}
|
|
||||||
|
|
||||||
let emojipediaResult = await emojipedia(context, emoji[0])
|
let res = await emojipedia(context, emoji[0])
|
||||||
emojipediaResult = emojipediaResult.response.body
|
res = res.response.body
|
||||||
|
|
||||||
if(!emojipediaResult.data.vendor_images[args.type]){
|
if(!res.data.vendor_images[args.type]){
|
||||||
let embed = createEmbed("error", context, "No emoji image available for platform " + args.type.toLowerCase() + ".")
|
let embed = createEmbed("error", context, "No emoji image available for platform '" + args.type.toLowerCase() + "'.")
|
||||||
embed.footer = {
|
embed.footer = {
|
||||||
text: "Available platforms: " + Object.keys(emojipediaResult.data.vendor_images).join(', ')
|
text: "Available platforms: " + Object.keys(res.data.vendor_images).join(', ').substr(0, 2000)
|
||||||
}
|
}
|
||||||
return await editOrReply(context, embed)
|
return await editOrReply(context, embed)
|
||||||
}
|
}
|
||||||
|
|
||||||
return editOrReply(context, {embeds:[
|
return editOrReply(context, createEmbed("default", context, {
|
||||||
createEmbed("default", context, {
|
author: {
|
||||||
description: `${emojipediaResult.data.emoji} • **${emojipediaResult.data.name}**`,
|
iconUrl: `https://abs.twimg.com/emoji/v2/72x72/${toCodePoint(emoji[0])}.png`,
|
||||||
image: {
|
name: res.data.name,
|
||||||
url: emojipediaResult.data.vendor_images[args.type]
|
url: res.data.permalink
|
||||||
},
|
},
|
||||||
footer: {
|
image: {
|
||||||
iconUrl: STATICS.emojipedia,
|
url: res.data.vendor_images[args.type]
|
||||||
text: `Emojipedia • ${context.application.name}`
|
},
|
||||||
}
|
footer: {
|
||||||
})
|
iconUrl: STATICS.emojipedia,
|
||||||
]})
|
text: `Emojipedia • ${context.application.name}`
|
||||||
|
}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -395,6 +395,7 @@ module.exports.EMOJIPEDIA_PLATFORM_TYPES = [
|
||||||
"toss-face",
|
"toss-face",
|
||||||
"microsoft-teams",
|
"microsoft-teams",
|
||||||
"animated-noto-color-emoji",
|
"animated-noto-color-emoji",
|
||||||
|
"twitter-emoji-stickers",
|
||||||
"emojipedia"
|
"emojipedia"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue