import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from 'discord.js'; import { Command } from '../../structures/Command.js'; import { Deployer } from '../../structures/Deployer.js'; const command: Command = { data: new SlashCommandBuilder() .setName('owner') .setDescription('Bot-Owner Commands') .addSubcommand(subcommand => subcommand .setName('deploy') .setDescription('Aktualisiert Commands')) .addSubcommand(subcommand => subcommand .setName('stats') .setDescription('Zeigt Bot-Statistiken')) .addSubcommand(subcommand => subcommand .setName('servers') .setDescription('Listet alle Server')) .setDMPermission(true), category: 'Owner', async execute(interaction: any, client: any) { if (!client.application?.owner) await client.application?.fetch(); if (interaction.user.id !== client.application?.owner?.id) { await interaction.reply({ content: 'Keine Berechtigung.', flags: [MessageFlags.Ephemeral] }); return; } const subcommand = interaction.options.getSubcommand(); if (subcommand === 'deploy') { await interaction.deferReply({ flags: [MessageFlags.Ephemeral] }); try { const count = await Deployer.deploy(client.user!.id, client.token!); await interaction.editReply(`✅ ${count} Befehle aktualisiert!`); } catch (error) { console.error(error); await interaction.editReply('❌ Fehler beim Deployment.'); } return; } if (subcommand === 'stats') { await interaction.deferReply({ flags: [MessageFlags.Ephemeral] }); const uptime = process.uptime(); const days = Math.floor(uptime / 86400); const hours = Math.floor(uptime / 3600) % 24; const minutes = Math.floor(uptime / 60) % 60; const uptimeStr = `${days}d ${hours}h ${minutes}m`; const totalServers = client.guilds.cache.size; const totalUsers = client.guilds.cache.reduce((acc: number, guild: any) => acc + guild.memberCount, 0); const embed = new EmbedBuilder() .setTitle('📊 Bot-Statistiken') .setColor(0x3498db) .addFields( { name: '🤖 Bot', value: `**Uptime:** ${uptimeStr}\n**Latency:** ${client.ws.ping}ms`, inline: true }, { name: '🌍 Netzwerk', value: `**Server:** ${totalServers}\n**Nutzer:** ${totalUsers}`, inline: true } ) .setTimestamp(); await interaction.editReply({ embeds: [embed] }); return; } if (subcommand === 'servers') { await interaction.deferReply({ flags: [MessageFlags.Ephemeral] }); const guilds = client.guilds.cache.map((guild: any) => `• **${guild.name}** \`(${guild.id})\` - ${guild.memberCount} Mitglieder` ); const chunks = []; for (let i = 0; i < guilds.length; i += 10) { chunks.push(guilds.slice(i, i + 10).join('\n')); } if (chunks.length === 0) { await interaction.editReply('Keine Server.'); return; } const embed = new EmbedBuilder() .setTitle(`🌍 Server (${client.guilds.cache.size})`) .setColor(0xf1c40f) .setDescription(chunks[0].substring(0, 4000)) .setTimestamp(); await interaction.editReply({ embeds: [embed] }); for (let i = 1; i < chunks.length; i++) { const nextEmbed = new EmbedBuilder() .setColor(0xf1c40f) .setDescription(chunks[i].substring(0, 4000)); await interaction.followUp({ embeds: [nextEmbed], flags: [MessageFlags.Ephemeral] }); } return; } }, }; export default command;