const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require('discord.js') module.exports = { data: new SlashCommandBuilder() .setName('server') .setDescription('Get information about the server.') .addSubcommand(subcommand => subcommand .setName('info') .setDescription(`Get information about the server.`)) .addSubcommand((subcommand => subcommand .setName(`icon`).setDescription(`Get the server icon.`))), async execute(interaction) { if (interaction.options.getSubcommand() === 'icon') { let embedServericon = new EmbedBuilder() .setTitle(`${interaction.guild.name} icon`) .setDescription(`[Download](${interaction.guild.iconURL({ size: 1024 , dynamic: true})})`) .setImage(`${interaction.guild.iconURL({ size: 1024, dynamic: true})}`) .setColor('#50c878') let errorEmbed = new EmbedBuilder() .setDescription('<:smike_x_mark:1009474223657463888> This server has no icon!') .setColor('#ff0000') return await interaction.reply({ embeds: [embedServericon] }).catch(err => { interaction.reply({ embeds: [errorEmbed], ephemeral: true}) }) } else if (interaction.options.getSubcommand() === 'info') { await interaction.deferReply() let owner = await interaction.guild.fetchOwner() let tChannels = interaction.guild.channels.cache.filter(channel => channel.type == ChannelType.GuildText).size let AnnChannels = interaction.guild.channels.cache.filter(channel => channel.type == ChannelType.GuildAnnouncement).size let totalText = tChannels + AnnChannels let VC = interaction.guild.channels.cache.filter(channel => channel.type == ChannelType.GuildVoice).size let stageChnl = interaction.guild.channels.cache.filter(channel => channel.type == ChannelType.GuildStageVoice).size let totalChannels = totalText + VC + stageChnl let Aniemojis = interaction.guild.emojis.cache.filter((e) => e.animated).size let staticMojis = interaction.guild.emojis.cache.filter((e) => !e.animated).size let totalEmojis = Aniemojis + staticMojis let embed = new EmbedBuilder() .setAuthor({ name:`Server info`, iconURL: `${interaction.guild.iconURL({ dynamic: true})}`}) .setThumbnail(interaction.guild.iconURL({ dynamic: true})) .setColor('#6f2da8') .setFooter({ text: `Server ID: ${interaction.guild.id}`}) .addFields( { name: `Server name`, value: `${interaction.guild.name}`, inline: true}, { name: `Owner`, value: `${owner}`, inline: true}, { name: `Roles`, value: `${interaction.guild.roles.cache.size - 1}`, inline: true}, { name: `Members`, value: `${interaction.guild.memberCount}`, inline: true}, { name: `Channels`, value: `\`\`\`Text: ${totalText}\nVoice: ${VC}\nStage: ${stageChnl}\nTotal: ${totalChannels}\`\`\``, inline: true}, { name: `Channel categories`, value: `${interaction.guild.channels.cache.filter(channel => channel.type == ChannelType.GuildCategory).size}`, inline: true}, { name: `Emojis`, value: `\`\`\`Animated: ${Aniemojis}\nStatic: ${staticMojis}\nTotal: ${totalEmojis}\`\`\`` }, { name: `Stickers`, value: `${interaction.guild.stickers.cache.size}`}, { name: `Boosts`, value: `${interaction.guild.premiumSubscriptionCount}`, inline: true}, { name: `Server created on`, value: new Date(interaction.guild.createdTimestamp).toLocaleDateString(), inline: true}, ) let embed2 = new EmbedBuilder() .setAuthor({ name:`Server info`}) .setColor('#6f2da8') .setFooter({ text: `Server ID: ${interaction.guild.id}`}) .addFields( { name: `Server name`, value: `${interaction.guild.name}`, inline: true}, { name: `Owner`, value: `${owner}`, inline: true}, { name: `Roles`, value: `${interaction.guild.roles.cache.size - 1}`, inline: true}, { name: `Members`, value: `${interaction.guild.memberCount}`, inline: true}, { name: `Channels`, value: `\`\`\`Text: ${totalText}\nVoice: ${VC}\nStage: ${stageChnl}\nTotal: ${totalChannels}\`\`\``, inline: true}, { name: `Channel categories`, value: `${interaction.guild.channels.cache.filter(channel => channel.type == ChannelType.GuildCategory).size}`, inline: true}, { name: `Emojis`, value: `\`\`\`Animated: ${Aniemojis}\nStatic: ${staticMojis}\nTotal: ${totalEmojis}\`\`\`` }, { name: `Stickers`, value: `${interaction.guild.stickers.cache.size}`}, { name: `Boosts`, value: `${interaction.guild.premiumSubscriptionCount}`, inline: true}, { name: `Server created on`, value: new Date(interaction.guild.createdTimestamp).toLocaleDateString(), inline: true}, ) await interaction.followUp({ embeds: [embed]}).catch(err => { return interaction.followUp({ embeds: [embed2]}) }) } } }