mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
fix various emoji-related issues
This commit is contained in:
parent
b1722564db
commit
e44ae18b81
4 changed files with 41 additions and 7 deletions
|
@ -135,12 +135,19 @@ module.exports = {
|
|||
|
||||
let res;
|
||||
try{
|
||||
res = await emojipedia(context, emoji[0])
|
||||
console.log(toCodePoint(emoji[0]))
|
||||
res = await emojipedia(context, emoji[0], toCodePoint(emoji[0]))
|
||||
res = res.response.body
|
||||
}catch(e){
|
||||
return await editOrReply(context, createEmbed("error", context, `No emoji data available for ${emoji[0]}.`))
|
||||
}
|
||||
|
||||
if(args.type == "twitter"){
|
||||
if(!context.message.content.includes("-type")){
|
||||
if(!res.data.platforms["twitter"]) args.type = Object.keys(res.data.platforms)[0]
|
||||
else args.type = "twitter"
|
||||
}
|
||||
}
|
||||
if(!res.data.platforms[args.type]){
|
||||
let embed = createEmbed("error", context, "No emoji image available for platform '" + args.type + "'.")
|
||||
embed.footer = {
|
||||
|
|
1
commands/message/utils/emoji.json
Normal file
1
commands/message/utils/emoji.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -11,6 +11,7 @@ const { Components, Snowflake } = require("detritus-client/lib/utils");
|
|||
const { bold } = require("detritus-client/lib/utils/markup");
|
||||
|
||||
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
||||
const ecache = require('./emoji.json')
|
||||
|
||||
function toCodePoint(unicodeSurrogates, sep) {
|
||||
var
|
||||
|
@ -82,15 +83,22 @@ module.exports = {
|
|||
ico = newView.data.platforms["twitter"].images[0].src
|
||||
if(!newView.data.platforms["twitter"]) ico = Object.values(newView.data.platforms)[0].images[0].src
|
||||
|
||||
let previewImage;
|
||||
if(!newView.data.platforms["twitter"]){
|
||||
newView.data.platforms[Object.keys(newView.data.platforms)[0]].images[0].src
|
||||
} else {
|
||||
previewImage = newView.data.platforms["twitter"].images[0].src
|
||||
}
|
||||
|
||||
currentView = createEmbed("default", context, {
|
||||
author: {
|
||||
iconUrl: ico,
|
||||
name: `${newView.data.name} • Emoji ${newView.data.metadata.version.emoji}`,
|
||||
name: `${newView.data.name} `,
|
||||
url: newView.data.link
|
||||
},
|
||||
description: newView.data.codes.map((c)=>pill(c)).join(' ') + "\n\n" + newView.data.metadata.description,
|
||||
image: {
|
||||
url: newView.data.platforms["twitter"].images[0].src
|
||||
url: previewImage
|
||||
},
|
||||
footer: {
|
||||
iconUrl: STATICS.emojipedia,
|
||||
|
@ -98,8 +106,13 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
|
||||
if(newView.data.metadata.version?.emoji){
|
||||
currentView.author.name += `• Emoji ${newView.data.metadata.version.emoji}`
|
||||
}
|
||||
|
||||
components.clear();
|
||||
if(newView.data.metadata.similar) for(const e of newView.data.metadata.similar.splice(0, 5)){
|
||||
if(!ecache.includes(e)) continue;
|
||||
components.addButton({
|
||||
customId: e,
|
||||
emoji: e,
|
||||
|
@ -114,6 +127,7 @@ module.exports = {
|
|||
})
|
||||
|
||||
if(res.data.metadata.similar) for(const e of res.data.metadata.similar.splice(0, 5)){
|
||||
if(!ecache.includes(e)) continue;
|
||||
components.addButton({
|
||||
customId: e,
|
||||
emoji: e,
|
||||
|
@ -132,15 +146,22 @@ module.exports = {
|
|||
let ico = `https://abs.twimg.com/emoji/v2/72x72/${toCodePoint(emoji[0])}.png`
|
||||
if(!res.data.platforms["twitter"]) ico = Object.values(res.data.platforms)[0].images[0].src
|
||||
|
||||
let iPreviewImage;
|
||||
if(!res.data.platforms["twitter"]){
|
||||
iPreviewImage = res.data.platforms[Object.keys(res.data.platforms)[0]].images[0].src
|
||||
} else {
|
||||
iPreviewImage = res.data.platforms["twitter"].images[0].src
|
||||
}
|
||||
|
||||
currentView = createEmbed("default", context, {
|
||||
author: {
|
||||
iconUrl: ico,
|
||||
name: `${res.data.name} • Unicode ${res.data.metadata.version.unicode}`,
|
||||
name: `${res.data.name} `,
|
||||
url: res.data.link
|
||||
},
|
||||
description: res.data.codes.map((c)=>pill(c)).join(' ') + "\n\n" + res.data.metadata.description,
|
||||
image: {
|
||||
url: res.data.platforms["twitter"].images[0].src
|
||||
url: iPreviewImage
|
||||
},
|
||||
footer: {
|
||||
iconUrl: STATICS.emojipedia,
|
||||
|
@ -148,6 +169,10 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
|
||||
if(res.data.metadata.version?.emoji){
|
||||
currentView.author.name += `• Emoji ${res.data.metadata.version.emoji}`
|
||||
}
|
||||
|
||||
if(!res.data.metadata.similar) return await editOrReply(context, currentView)
|
||||
|
||||
return editOrReply(context, {
|
||||
|
|
|
@ -304,10 +304,11 @@ module.exports.dictionary = async function(context, query, language){
|
|||
})
|
||||
}
|
||||
|
||||
module.exports.emojipedia = async function(context, emoji){
|
||||
module.exports.emojipedia = async function(context, emoji, codepoint = undefined){
|
||||
return await request(Api.UTILS_EMOJIPEDIA, "GET", {}, {
|
||||
emoji: emoji,
|
||||
with_metadata: ""
|
||||
with_metadata: "",
|
||||
codepoint
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue