galactic-bot/structure/client/components/commands/information/Guild.js
2020-08-06 01:13:09 +03:00

62 lines
1.7 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,
totalChannels = 0;
const createdAt = `${guild.createdAt.toDateString()} (${this.client.resolver.timeAgo(Math.floor(Date.now() / 1000) - Math.floor(guild.createdTimestamp / 1000))} ago)`;
const description = guild._settings.description || message.format('C_GUILD_NODESC');
const maxMembers = guild.maximumMembers;
for (const channel of guild.channels.cache.values()) {
if (channel.type === 'voice') vc++;
if (channel.type === 'text') tc++;
totalChannels++;
}
return message.embed({
description: message.format('C_GUILD_TEMPLATE', {
createdAt,
description,
maxMembers,
totalChannels,
vc,
tc,
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
}),
thumbnail: {
url: guild.iconURL()
}
});
}
}
module.exports = GuildCommand;