mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
support for multiple emoji in enlarge
This commit is contained in:
parent
1a4d2732b8
commit
0125663079
2 changed files with 69 additions and 28 deletions
|
@ -1,8 +1,8 @@
|
||||||
const { emojipedia, emojiKitchen } = require("#api");
|
const { emojipedia, emojiKitchen } = require("#api");
|
||||||
|
|
||||||
const { createEmbed } = require("#utils/embed");
|
const { createEmbed, formatPaginationEmbeds } = require("#utils/embed");
|
||||||
const { acknowledge } = require("#utils/interactions");
|
const { acknowledge } = require("#utils/interactions");
|
||||||
const { icon, pill, iconPill, highlight, timestamp } = require("#utils/markdown");
|
const { pill, timestamp } = require("#utils/markdown");
|
||||||
const { editOrReply } = require("#utils/message");
|
const { editOrReply } = require("#utils/message");
|
||||||
const { STATICS, STATIC_ASSETS } = require("#utils/statics");
|
const { STATICS, STATIC_ASSETS } = require("#utils/statics");
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ const { Utils } = require("detritus-client");
|
||||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes, DiscordRegexNames, InteractionContextTypes, ApplicationIntegrationTypes } = require("detritus-client/lib/constants");
|
const { InteractionCallbackTypes, ApplicationCommandOptionTypes, DiscordRegexNames, InteractionContextTypes, ApplicationIntegrationTypes } = require("detritus-client/lib/constants");
|
||||||
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
||||||
const { PERMISSION_GROUPS } = require("#constants");
|
const { PERMISSION_GROUPS } = require("#constants");
|
||||||
|
const { paginator } = require("#client");
|
||||||
|
|
||||||
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
||||||
|
|
||||||
|
@ -74,19 +75,40 @@ module.exports = {
|
||||||
embeds = []
|
embeds = []
|
||||||
if (matches.length) {
|
if (matches.length) {
|
||||||
ingest("emoji_enlarge", "slash_command_ran");
|
ingest("emoji_enlarge", "slash_command_ran");
|
||||||
let form = '.png'
|
|
||||||
if(matches[0].animated) form = '.gif'
|
let pages = [];
|
||||||
|
let entries = [];
|
||||||
let tagline = ''
|
for(const m of matches){
|
||||||
tagline += `\n${icon("clock")} Created ${timestamp(Snowflake.timestamp(matches[0].id), "f")}`
|
if(entries.map((e)=>e.id).includes(m.id)) continue;
|
||||||
|
entries.push(m)
|
||||||
return editOrReply(context, createEmbed("default", context, {
|
}
|
||||||
description: `${iconPill("emoji", `:${matches[0].name}:`)} ${highlight(`(${matches[0].id})`)}${tagline}`,
|
|
||||||
image: {
|
while(entries.length){
|
||||||
url: `https://cdn.discordapp.com/emojis/${matches[0].id}${form}?size=4096`
|
let sprites = entries.splice(0, 4);
|
||||||
|
let embeds = [];
|
||||||
|
for(const s of sprites){
|
||||||
|
let fields = sprites.map((s)=>{return {inline: true,name:`\\:${s.name}\\:`,value:`-# Created ${timestamp(Snowflake.timestamp(s.id),"R")}${context.guild.emojis.find((e)=>e.id == matches[0].id) ? "\n-# Custom emoji is from this server" : ""}`}});
|
||||||
|
if(fields.length >= 3){
|
||||||
|
fields.splice(2,0,{name:` `, value:` `, inline:true})
|
||||||
|
if(fields.length == 5) fields.push({name:` `, value:` `, inline:true})
|
||||||
}
|
}
|
||||||
|
embeds.push(createEmbed("default", context, {
|
||||||
|
url: "https://bignutty.gitlab.io",
|
||||||
|
fields,
|
||||||
|
image: {
|
||||||
|
url: `https://cdn.discordapp.com/emojis/${s.id}${s.animated ? ".gif" : ".png"}?size=4096`
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
pages.push({
|
||||||
|
embeds
|
||||||
})
|
})
|
||||||
)
|
}
|
||||||
|
|
||||||
|
return await paginator.createPaginator({
|
||||||
|
context,
|
||||||
|
pages: formatPaginationEmbeds(pages)
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const emoji = onlyEmoji(args.emoji)
|
const emoji = onlyEmoji(args.emoji)
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@ const { emojipedia, emojiKitchen } = require("#api");
|
||||||
const { EMOJIPEDIA_PLATFORM_TYPES, EMOJIPEDIA_PLATFORM_TYPE_ALIASES, PERMISSION_GROUPS } = require("#constants");
|
const { EMOJIPEDIA_PLATFORM_TYPES, EMOJIPEDIA_PLATFORM_TYPE_ALIASES, PERMISSION_GROUPS } = require("#constants");
|
||||||
const { ingest } = require("#logging");
|
const { ingest } = require("#logging");
|
||||||
|
|
||||||
const { createEmbed } = require("#utils/embed");
|
const { createEmbed, formatPaginationEmbeds } = require("#utils/embed");
|
||||||
const { icon, pill, iconPill, highlight, timestamp, smallIconPill } = require("#utils/markdown");
|
const { pill, iconPill, highlight, timestamp, smallIconPill } = require("#utils/markdown");
|
||||||
const { editOrReply } = require("#utils/message");
|
const { editOrReply } = require("#utils/message");
|
||||||
const { STATICS, STATIC_ASSETS } = require("#utils/statics");
|
const { STATICS, STATIC_ASSETS } = require("#utils/statics");
|
||||||
|
|
||||||
const { Utils } = require("detritus-client");
|
const { Utils } = require("detritus-client");
|
||||||
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
const { Components, Snowflake } = require("detritus-client/lib/utils");
|
||||||
const { InteractionCallbackTypes, DiscordRegexNames } = require("detritus-client/lib/constants");
|
const { InteractionCallbackTypes, DiscordRegexNames } = require("detritus-client/lib/constants");
|
||||||
const { bold } = require("detritus-client/lib/utils/markup");
|
|
||||||
const { acknowledge } = require("#utils/interactions");
|
const { acknowledge } = require("#utils/interactions");
|
||||||
|
const { paginator } = require("#client");
|
||||||
|
|
||||||
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
const onlyEmoji = require('emoji-aware').onlyEmoji;
|
||||||
|
|
||||||
|
@ -85,28 +85,47 @@ module.exports = {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { matches } = Utils.regex(
|
let { matches } = Utils.regex(
|
||||||
DiscordRegexNames.EMOJI,
|
DiscordRegexNames.EMOJI,
|
||||||
args.emoji
|
args.emoji
|
||||||
);
|
);
|
||||||
embeds = []
|
embeds = []
|
||||||
if (matches.length) {
|
if (matches.length) {
|
||||||
ingest("emoji_enlarge", "command_ran");
|
ingest("emoji_enlarge", "command_ran");
|
||||||
let form = '.png'
|
|
||||||
if(matches[0].animated) form = '.gif'
|
|
||||||
|
|
||||||
let tagline = ''
|
let pages = [];
|
||||||
tagline += `\n${icon("clock")} Created ${timestamp(Snowflake.timestamp(matches[0].id), "f")}`
|
let entries = [];
|
||||||
if(context.guild.emojis.find((e)=>e.id == matches[0].id)) tagline += `\n${icon("home")} This custom emoji is from ${bold(context.guild.name)}`
|
for(const m of matches){
|
||||||
|
if(entries.map((e)=>e.id).includes(m.id)) continue;
|
||||||
|
entries.push(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
while(entries.length){
|
||||||
return editOrReply(context, createEmbed("default", context, {
|
let sprites = entries.splice(0, 4);
|
||||||
description: `${iconPill("emoji", `:${matches[0].name}:`)} ${highlight(`(${matches[0].id})`)}${tagline}`,
|
let embeds = [];
|
||||||
image: {
|
for(const s of sprites){
|
||||||
url: `https://cdn.discordapp.com/emojis/${matches[0].id}${form}?size=4096`
|
let fields = sprites.map((s)=>{return {inline: true,name:`\\:${s.name}\\:`,value:`-# Created ${timestamp(Snowflake.timestamp(s.id),"R")}${context.guild.emojis.find((e)=>e.id == matches[0].id) ? "\n-# Custom emoji is from this server" : ""}`}});
|
||||||
|
if(fields.length >= 3){
|
||||||
|
fields.splice(2,0,{name:` `, value:` `, inline:true})
|
||||||
|
if(fields.length == 5) fields.push({name:` `, value:` `, inline:true})
|
||||||
}
|
}
|
||||||
|
embeds.push(createEmbed("default", context, {
|
||||||
|
url: "https://bignutty.gitlab.io",
|
||||||
|
fields,
|
||||||
|
image: {
|
||||||
|
url: `https://cdn.discordapp.com/emojis/${s.id}${s.animated ? ".gif" : ".png"}?size=4096`
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
pages.push({
|
||||||
|
embeds
|
||||||
})
|
})
|
||||||
)
|
}
|
||||||
|
|
||||||
|
return await paginator.createPaginator({
|
||||||
|
context,
|
||||||
|
pages: formatPaginationEmbeds(pages)
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const emoji = onlyEmoji(args.emoji)
|
const emoji = onlyEmoji(args.emoji)
|
||||||
if(!emoji){
|
if(!emoji){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue