constatic
Version:
Constatic cli
2 lines (1 loc) • 1.88 kB
JavaScript
import{discordEmojis as B,divider as d,log as t,sleep as f,uiMessage as o}from"#helpers";import{menus as l}from"#menus";import{withDefaults as g}from"#prompts";import{checkbox as $,confirm as x}from"@inquirer/prompts";import e from"chalk";import D from"ora";import{fetchDiscordEmojis as P}from"./fetch.js";async function z(r,n){const m=await P({props:r,token:n});if(!m)return;const w=m.map((i,a)=>({name:[i.animated?e.magenta("(animated)"):e.cyan("(static)"),e.yellow(i.name),e.dim.green(i.id)].join(" "),value:a})),s=await $(g({message:o({"en-US":"Select the emojis you want to delete","pt-BR":"Selecione os emojis que deseja deletar"}),pageSize:10,choices:w}));if(d(),s.length<1){t.warn(o({"en-US":"No emoji selected, back to emojis menu","pt-BR":"Nenhum emoji selecionado, voltando ao menu de emojis"})),await f(500),l.discord.emojis.main(r);return}const u=e.underline(`${s.length} emoji${s.length>1?"s":""}`);if(t.warn(o({"en-US":`You are about to delete ${u}!`,"pt-BR":`Voc\xEA est\xE1 prestes a excluir ${u}!`})),!await x(g({message:o({"en-US":"Do you want to continue?","pt-BR":"Deseja continuar?"})}))){l.discord.emojis.main(r,n);return}const p=[],j=D();j.start(o({"en-US":"Preparing to delete emojis...","pt-BR":"Preparando para excluir emojis..."}));for(const i of s){const a=m[i],c=e.yellow.underline(a.name),h=B.delete(n,a.id).then(S=>{S.success||t.error(o({"en-US":`An error occurred while trying delete the emoji ${c}!`,"pt-BR":`Ocorreu um erro ao tentar excluir o emoji ${c}!`},e.red)),t.custom(e.red(t.icon.success),o({"en-US":`${e.red.bold("Deleted")} \u2192 ${c}`,"pt-BR":`${e.bgRed.bold("Exclu\xEDdo")} \u2192 ${c}`}))});p.push(h)}j.stop(),await Promise.all(p),d(),t.success(o({"en-US":"Deleting process completed!","pt-BR":"Processo de exclus\xE3o conclu\xEDdo!"},e.green)),d(),await f(500),l.discord.emojis.main(r,n)}export{z as discordEmojisDeleteMenu};