galactic-bot/structure/client/components/commands/information/Guild.js

146 lines
5.0 KiB
JavaScript

const { Command } = require('../../../../interfaces');
class GuildCommand extends Command {
constructor(client) {
super(client, {
name: 'guild',
module: 'information',
aliases: [
'server'
]
});
this.client = client;
}
async execute(message) {
const guild = await message.guild.fetch();
let vc = 0,
tc = 0,
cat = 0,
news = 0,
store = 0,
totalChannels = 0;
const createdAt = `${guild.createdAt.toDateString()} (${this.client.resolver.timeAgo(Math.floor(Date.now() / 1000) - Math.floor(guild.createdTimestamp / 1000))} ago)`,
description = guild.description || guild._settings.description || message.format('C_GUILD_NODESC'),
maxMembers = guild.maximumMembers,
maxPresences = guild.maximumPresences,
approxPresences = guild.approximatePresenceCount,
{ memberCount } = guild;
for (const channel of guild.channels.cache.values()) {
if (channel.type === 'voice') vc++;
if (channel.type === 'text') tc++;
if (channel.type === 'category') cat++;
if (channel.type === 'news') news++;
if (channel.type === 'store') store++;
totalChannels++;
}
const embed = {
description: message.format('C_GUILD_TEMPLATE', {
name: guild.name,
description,
owner: guild.owner.id,
id: guild.id,
shard: guild.shardID,
createdAt,
region: guild.region,
boosters: guild.premiumSubscriptionCount,
tier: guild.premiumTier
}),
fields: [
{
name: message.format('C_GUILD_MEMBERS_NAME'),
value: message.format('C_GUILD_MEMBERS', {
memberCount,
maxMembers,
maxPresences,
approxPresences
}),
inline: true
},
{
name: message.format('C_GUILD_CHANNELS_NAME'),
value: message.format('C_GUILD_CHANNELS', {
vc,
tc,
cat,
news: news > 0 ? message.format('C_GUILD_NEWS', { news }) : '',
store: store > 0 ? message.format('C_GUILD_STORE', { store }) : '',
totalChannels
}),
inline: true
},
{
name: message.format('C_GUILD_OTHER_NAME'),
value: message.format('C_GUILD_OTHER', {
roleCount: guild.roles.cache.size,
emojiCount: guild.emojis.cache.filter((e) => !e.animated).size,
gifEmojiCount: guild.emojis.cache.filter((e) => e.animated).size,
emojiTotal: 50 + 50 * guild.premiumTier
}),
inline: true
}
],
thumbnail: {
url: guild.iconURL()
},
footer: {
text: `• Server ID: ${guild.id} • Shard ID: ${guild.shardID}`
}
};
if (guild.features.length) embed.fields.push({
name: message.format('C_GUILD_FEATURES_NAME'),
value: message.format('C_GUILD_FEATURES', {
features: guild.features.join(', ')
}),
inline: true
});
return message.embed(embed);
// return message.embed({
// description: message.format('C_GUILD_TEMPLATE', {
// createdAt,
// description,
// maxMembers,
// approxPresences: guild.approximatePresenceCount,
// maxPresences: guild.maximumPresences,
// totalChannels,
// vc,
// tc,
// cat,
// news,
// owner: guild.owner.id,
// id: guild.id,
// name: guild.name,
// region: guild.region,
// members: guild.memberCount,
// boosters: guild.premiumSubscriptionCount,
// tier: guild.premiumTier,
// shard: guild.shardID,
// roleCount: guild.roles.cache.size,
// emojiCount: guild.emojis.cache.filter((e) => !e.animated).size,
// gifEmojiCount: guild.emojis.cache.filter((e) => e.animated).size,
// emojiTotal: 50 + 50 * guild.premiumTier,
// features: guild.features.length ? guild.features.join(', ') : message.format('C_GUILD_NOFEAT')
// }),
// thumbnail: {
// url: guild.iconURL()
// }
// });
}
}
module.exports = GuildCommand;