import { SlashCommandBuilder, ChatInputCommandInteraction, EmbedBuilder } from 'discord.js';
import { SlashCommand } from '../../utils/types';

const command: SlashCommand = {
  guildOnly: true,
  data: new SlashCommandBuilder().setName('serverinfo').setDescription('Zeigt Infos zum aktuellen Server.'),
  async execute(interaction: ChatInputCommandInteraction) {
    const guild = interaction.guild!;
    const embed = new EmbedBuilder()
      .setTitle(guild.name)
      .setThumbnail(guild.iconURL() ?? null)
      .addFields(
        { name: 'Mitglieder', value: `${guild.memberCount}`, inline: true },
        { name: 'Erstellt', value: `<t:${Math.floor(guild.createdTimestamp / 1000)}:R>`, inline: true },
        { name: 'ID', value: guild.id, inline: true }
      );
    await interaction.reply({ embeds: [embed] });
  }
};

export default command;
