jillo-bot/src/commands/emotedump.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-11-21 20:17:15 +01:00
import { EmbedBuilder, SlashCommandBuilder, CommandInteraction } from 'discord.js';
2022-08-26 18:42:48 +02:00
import { writeTmpFile } from '../lib/util';
2023-11-16 11:33:11 +01:00
import { Command } from '../types/index';
2022-08-26 18:42:48 +02:00
2023-11-16 11:33:11 +01:00
export default {
2022-08-26 18:42:48 +02:00
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)
),
2023-11-16 11:33:11 +01:00
execute: async (interaction: CommandInteraction) => {
if (!interaction.isChatInputCommand()) return;
2022-08-26 18:53:44 +02:00
const size = interaction.options.getInteger('size') || 64;
2023-11-16 11:33:11 +01:00
const emojis = interaction.guild!.emojis;
2022-08-26 18:42:48 +02:00
const embed = new EmbedBuilder()
2022-08-26 18:42:48 +02:00
.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
});
}
2023-11-16 11:33:11 +01:00
} satisfies Command;