import { EmbedBuilder, SlashCommandBuilder, CommandInteraction } from 'discord.js'; import { writeTmpFile } from '../lib/util'; import { Command } from '../types/index'; export default { data: new SlashCommandBuilder() .setName('emotedump') .setDescription('Dump every emote in the server for Gitea') .addIntegerOption((option) => option .setName('size') .setRequired(false) .setDescription('Image size to output the emojis as, leave unset if unsure') .setMinValue(16) .setMaxValue(512) ), execute: async (interaction: CommandInteraction) => { if (!interaction.isChatInputCommand()) return; const size = interaction.options.getInteger('size') || 64; const emojis = interaction.guild!.emojis; const embed = new EmbedBuilder() .setDescription(`names: \`${emojis.cache.map(emote => emote.name).join(',')}\``); const commands = [ ...emojis.cache.map(emote => `wget -q "https://cdn.discordapp.com/emojis/${emote.id}.${emote.animated ? 'gif' : 'png'}?size=${size}&quality=lossless" -O "${emote.name}.png"` ), 'chown gitea:gitea ./*' ].join('\n'); const attach = await writeTmpFile(commands, 'commands', 'sh'); interaction.reply({ embeds: [embed], files: [attach], ephemeral: true }); } } satisfies Command;