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

118 lines
3.9 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',
clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'],
2020-05-24 23:40:38 +02:00
aliases: [
'server'
2020-05-24 23:40:38 +02:00
]
});
this.client = client;
}
2021-06-23 10:51:34 +02:00
async execute(message, { params }) {
2020-05-24 23:40:38 +02:00
2021-06-23 10:51:34 +02:00
let guild = null;
//if(params[0]) guild = await this.client.fetchGuildPreview(params[0]);
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,
2020-10-14 20:11:04 +02:00
owner: guild.ownerID,
2020-05-24 23:40:38 +02:00
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);
2020-05-24 23:40:38 +02:00
}
}
module.exports = GuildCommand;