import { ChannelType, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js'; import { SlashCommand } from '../../utils/types'; import { context } from '../../config/context'; import { settingsStore } from '../../config/state'; const command: SlashCommand = { guildOnly: true, data: new SlashCommandBuilder() .setName('gallery') .setDescription('Screenshot-/Kunst-Galerie.') .addSubcommand((sub) => sub .setName('submit') .setDescription('Reicht ein Bild für die Galerie ein.') .addAttachmentOption((opt) => opt.setName('image').setDescription('Bild').setRequired(true)) .addStringOption((opt) => opt.setName('caption').setDescription('Beschreibung')) ) .addSubcommand((sub) => sub .setName('config') .setDescription('Konfiguriert Galerie-Kanal und Künstler-Rolle.') .addChannelOption((opt) => opt.setName('channel').setDescription('Galerie-Kanal').addChannelTypes(ChannelType.GuildText)) .addRoleOption((opt) => opt.setName('artist_role').setDescription('Rolle für Künstler')) ), async execute(interaction: ChatInputCommandInteraction) { if (!interaction.guildId) return; const sub = interaction.options.getSubcommand(); if (sub === 'submit') { const attachment = interaction.options.getAttachment('image', true); const caption = interaction.options.getString('caption') ?? undefined; await context.gallery.submit(interaction, attachment, caption); return; } if (sub === 'config') { if (!interaction.memberPermissions?.has(PermissionFlagsBits.ManageGuild)) { await interaction.reply({ content: 'Du benötigst die Berechtigung "Server verwalten".', ephemeral: true }); return; } const channel = interaction.options.getChannel('channel'); const role = interaction.options.getRole('artist_role'); const current = settingsStore.get(interaction.guildId)?.galleryConfig || {}; await settingsStore.set(interaction.guildId, { galleryConfig: { channelId: channel?.id ?? current.channelId, artistRoleId: role?.id ?? current.artistRoleId, lastWinnerAt: current.lastWinnerAt } }); await interaction.reply({ content: 'Galerie-Konfiguration aktualisiert.', ephemeral: true }); } } }; export default command;