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

146 lines
5.0 KiB
JavaScript
Raw Normal View History

2020-06-19 23:02:16 +02:00
const { Command } = require('../../../../interfaces');
2020-05-24 23:40:38 +02:00
class GuildCommand extends Command {
constructor(client) {
super(client, {
name: 'guild',
2020-06-19 23:02:16 +02:00
module: 'information',
2020-05-24 23:40:38 +02:00
aliases: [
'server'
2020-05-24 23:40:38 +02:00
]
});
this.client = client;
}
async execute(message) {
2020-08-06 00:13:09 +02:00
const guild = await message.guild.fetch();
2020-05-24 23:40:38 +02:00
let vc = 0,
2020-08-06 00:13:09 +02:00
tc = 0,
2020-08-08 20:59:30 +02:00
cat = 0,
news = 0,
store = 0,
2020-08-06 00:13:09 +02:00
totalChannels = 0;
2020-08-08 20:59:30 +02:00
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;
2020-05-24 23:40:38 +02:00
for (const channel of guild.channels.cache.values()) {
if (channel.type === 'voice') vc++;
if (channel.type === 'text') tc++;
2020-08-08 20:59:30 +02:00
if (channel.type === 'category') cat++;
if (channel.type === 'news') news++;
if (channel.type === 'store') store++;
2020-08-06 00:13:09 +02:00
totalChannels++;
2020-05-24 23:40:38 +02:00
}
2020-08-08 20:59:30 +02:00
const embed = {
2020-05-24 23:40:38 +02:00
description: message.format('C_GUILD_TEMPLATE', {
2020-08-08 20:59:30 +02:00
name: guild.name,
2020-05-24 23:40:38 +02:00
description,
owner: guild.owner.id,
id: guild.id,
2020-08-08 20:59:30 +02:00
shard: guild.shardID,
createdAt,
2020-05-24 23:40:38 +02:00
region: guild.region,
2020-06-19 23:02:16 +02:00
boosters: guild.premiumSubscriptionCount,
2020-08-08 20:59:30 +02:00
tier: guild.premiumTier
2020-05-24 23:40:38 +02:00
}),
2020-08-08 20:59:30 +02:00
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
}
],
2020-05-24 23:40:38 +02:00
thumbnail: {
url: guild.iconURL()
2020-08-14 21:44:52 +02:00
},
footer: {
text: `• Server ID: ${guild.id} • Shard ID: ${guild.shardID}`
2020-05-24 23:40:38 +02:00
}
2020-08-08 20:59:30 +02:00
};
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
2020-05-24 23:40:38 +02:00
});
2020-08-08 20:59:30 +02:00
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()
// }
// });
2020-05-24 23:40:38 +02:00
}
}
module.exports = GuildCommand;