Files
pixelpoebel/src/commands/utility/cat.ts
sarah ddfc82e1c5
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s
feat: add Cat module with /cat and /catgif commands using TheCatAPI
2026-08-02 23:08:29 +02:00

41 lines
1.5 KiB
TypeScript

import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { Command } from '../../structures/Command.js';
import { CatManager } from '../../structures/CatManager.js';
const command: Command = {
data: new SlashCommandBuilder()
.setName('cat')
.setDescription('Postet ein zufälliges Katzenbild oder Katzen-GIF.')
.addStringOption(option =>
option.setName('typ')
.setDescription('Wähle zwischen Bild oder GIF')
.setRequired(false)
.addChoices(
{ name: 'Bild', value: 'image' },
{ name: 'GIF', value: 'gif' }
))
.setDMPermission(true),
category: 'Public',
async execute(interaction: any) {
const type = (interaction.options.getString('typ') as 'image' | 'gif') || 'image';
await interaction.deferReply();
const imageUrl = await CatManager.fetchCatImage(type);
if (!imageUrl) {
await interaction.editReply('❌ Konnte kein Katzenbild laden. Bitte versuche es später erneut.');
return;
}
const embed = new EmbedBuilder()
.setTitle(type === 'gif' ? '🐱 Zufälliges Katzen-GIF' : '🐱 Zufälliges Katzenbild')
.setURL(imageUrl)
.setImage(imageUrl)
.setColor(0xf39c12)
.setTimestamp();
await interaction.editReply({ embeds: [embed] });
},
};
export default command;