aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-21 23:35:13 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-21 23:35:13 -0400
commit44521f4560dc8b0bab055685437d8fa65a34377f (patch)
tree4750c8cf696a2489964edc409e640f6792ed92b6 /src/commands/info
parenta8b3f2d258d6ef19aeff2c9d60d6b08a91277b2b (diff)
downloadtanzanite-44521f4560dc8b0bab055685437d8fa65a34377f.tar.gz
tanzanite-44521f4560dc8b0bab055685437d8fa65a34377f.tar.bz2
tanzanite-44521f4560dc8b0bab055685437d8fa65a34377f.zip
misc
Diffstat (limited to 'src/commands/info')
-rw-r--r--src/commands/info/guildInfo.ts98
-rw-r--r--src/commands/info/help.ts15
-rw-r--r--src/commands/info/links.ts2
-rw-r--r--src/commands/info/snowflake.ts2
-rw-r--r--src/commands/info/userInfo.ts3
5 files changed, 47 insertions, 73 deletions
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 4a79918..44c388d 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -45,6 +45,7 @@ export default class GuildInfoCommand extends BushCommand {
`${util.emojis.error} You must either provide an server to provide info about or run this command in a server.`
);
}
+ const otherEmojis = client.consts.mappings.otherEmojis;
let isPreview = false;
if (['number', 'string'].includes(typeof args?.guild)) {
const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {});
@@ -61,47 +62,27 @@ export default class GuildInfoCommand extends BushCommand {
const guildStats: string[] = [];
const guildSecurity: string[] = [];
const verifiedGuilds = Object.values(client.consts.mappings.guilds);
- if (verifiedGuilds.includes(guild.id)) emojis.push(client.consts.mappings.otherEmojis.BUSH_VERIFIED);
+ if (verifiedGuilds.includes(guild.id)) emojis.push(otherEmojis.BUSH_VERIFIED);
if (!isPreview && guild instanceof Guild) {
- if (guild.premiumTier)
- emojis.push(
- client.consts.mappings.otherEmojis[`BOOST_${guild.premiumTier}` as keyof typeof client.consts.mappings.otherEmojis]
- );
+ if (guild.premiumTier !== 'NONE') emojis.push(otherEmojis[`BOOST_${guild.premiumTier}`]);
await guild.fetch();
+ const channels = guild.channels.cache;
const channelTypes = [
- `${client.consts.mappings.otherEmojis.TEXT} ${guild.channels.cache
- .filter((channel) => channel.type === 'GUILD_TEXT')
- .size.toLocaleString()}`,
- `${client.consts.mappings.otherEmojis.NEWS} ${guild.channels.cache
- .filter((channel) => channel.type === 'GUILD_NEWS')
- .size.toLocaleString()}`,
- `${client.consts.mappings.otherEmojis.VOICE} ${guild.channels.cache
- .filter((channel) => channel.type === 'GUILD_VOICE')
- .size.toLocaleString()}`,
- `${client.consts.mappings.otherEmojis.STAGE} ${guild.channels.cache
- .filter((channel) => channel.type === 'GUILD_STAGE_VOICE')
- .size.toLocaleString()}`,
- `${client.consts.mappings.otherEmojis.STORE} ${guild.channels.cache
- .filter((channel) => channel.type === 'GUILD_STORE')
- .size.toLocaleString()}`,
- `${client.consts.mappings.otherEmojis.CATEGORY} ${guild.channels.cache
- .filter((channel) => channel.type === 'GUILD_CATEGORY')
- .size.toLocaleString()}`,
- `${client.consts.mappings.otherEmojis.THREAD} ${guild.channels.cache
- .filter((channel) =>
- ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD', 'GUILD_STAGE_VOICE'].includes(channel.type)
- )
- .size.toLocaleString()}`
+ `${otherEmojis.TEXT} ${channels.filter((channel) => channel.type === 'GUILD_TEXT').size.toLocaleString()}`,
+ `${otherEmojis.NEWS} ${channels.filter((channel) => channel.type === 'GUILD_NEWS').size.toLocaleString()}`,
+ `${otherEmojis.VOICE} ${channels.filter((channel) => channel.type === 'GUILD_VOICE').size.toLocaleString()}`,
+ `${otherEmojis.STAGE} ${channels.filter((channel) => channel.type === 'GUILD_STAGE_VOICE').size.toLocaleString()}`,
+ `${otherEmojis.STORE} ${channels.filter((channel) => channel.type === 'GUILD_STORE').size.toLocaleString()}`,
+ `${otherEmojis.CATEGORY} ${channels.filter((channel) => channel.type === 'GUILD_CATEGORY').size.toLocaleString()}`,
+ `${otherEmojis.THREAD} ${channels.filter((channel) => channel.type.includes('_THREAD')).size.toLocaleString()}`
];
- const guildRegions: string[] = [];
- guild.channels.cache.forEach((channel) => {
- if (!channel.type.includes('VOICE')) return;
- else if (!guildRegions.includes((channel as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')) {
- guildRegions.push((channel as BaseGuildVoiceChannel).rtcRegion ?? 'automatic');
- }
- });
+ const guildRegions = [
+ ...new Set(
+ guild.channels.cache.filter((c) => c.isVoice()).map((c) => (c as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')
+ )
+ ] as RTCRegion[];
guildAbout.push(
`**Owner:** ${guild.members.cache.get(guild.ownerId)?.user.tag}`,
@@ -109,9 +90,7 @@ export default class GuildInfoCommand extends BushCommand {
`**Members:** ${guild.memberCount.toLocaleString() ?? 0} (${util.emojis.onlineCircle} ${
guild.approximatePresenceCount?.toLocaleString() ?? 0
}, ${util.emojis.offlineCircle} ${(guild.memberCount - (guild.approximatePresenceCount ?? 0)).toLocaleString() ?? 0})`,
- `**Regions:** ${guildRegions
- .map((region) => client.consts.mappings.regions[region as keyof typeof client.consts.mappings.regions] || region)
- .join(', ')}`
+ `**Regions:** ${guildRegions.map((region) => client.consts.mappings.regions[region] || region).join(', ')}`
);
if (guild.premiumSubscriptionCount)
guildAbout.push(
@@ -171,28 +150,21 @@ export default class GuildInfoCommand extends BushCommand {
);
}
+ const features = client.consts.mappings.features;
const guildFeatures = guild.features.sort((a, b): number => {
- const aWeight = client.consts.mappings.features[a]?.weight;
- const bWeight = client.consts.mappings.features[b]?.weight;
+ const aWeight = features[a]?.weight;
+ const bWeight = features[b]?.weight;
- if (aWeight != undefined && bWeight != undefined) {
- return aWeight - bWeight;
- } else if (aWeight == undefined) {
- return 1;
- } else if (bWeight == undefined) {
- return -1;
- }
+ if (aWeight !== undefined && bWeight !== undefined) return aWeight - bWeight;
+ else if (aWeight == undefined) return 1;
+ else if (bWeight == undefined) return -1;
return 0;
});
if (guildFeatures.length) {
guildFeatures.forEach((feature) => {
- if (client.consts.mappings.features[feature]?.emoji) {
- emojis.push(`${client.consts.mappings.features[feature].emoji}`);
- } else if (client.consts.mappings.features[feature]?.name) {
- emojis.push(`\`${client.consts.mappings.features[feature].name}\``);
- } else {
- emojis.push(`\`${feature}\``);
- }
+ if (features[feature]?.emoji) emojis.push(`${features[feature].emoji}`);
+ else if (features[feature]?.name) emojis.push(`\`${features[feature].name}\``);
+ else emojis.push(`\`${feature}\``);
});
}
@@ -204,7 +176,7 @@ export default class GuildInfoCommand extends BushCommand {
.setTitle(guild.name)
.setColor(util.colors.default)
.addField('» About', guildAbout.join('\n'));
- if (guildStats) guildInfoEmbed.addField('» Stats', guildStats.join('\n'));
+ if (guildStats.length) guildInfoEmbed.addField('» Stats', guildStats.join('\n'));
const guildIcon = guild.iconURL({ size: 2048, format: 'png', dynamic: true });
if (guildIcon) {
guildInfoEmbed.setThumbnail(guildIcon);
@@ -218,3 +190,19 @@ export default class GuildInfoCommand extends BushCommand {
return await message.util.reply({ embeds: [guildInfoEmbed] });
}
}
+
+type RTCRegion =
+ | 'us-west'
+ | 'us-east'
+ | 'us-central'
+ | 'us-south'
+ | 'singapore'
+ | 'southafrica'
+ | 'sydney'
+ | 'europe'
+ | 'brazil'
+ | 'hongkong'
+ | 'russia'
+ | 'japan'
+ | 'india'
+ | 'automatic';
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 5e80199..440bcb2 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -22,11 +22,7 @@ export default class HelpCommand extends BushCommand {
optional: true
}
},
- {
- id: 'showHidden',
- match: 'flag',
- flag: '--hidden'
- }
+ { id: 'showHidden', match: 'flag', flag: '--hidden' }
],
slash: true,
slashOptions: [
@@ -46,11 +42,7 @@ export default class HelpCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: { command: BushCommand | string; showHidden?: boolean }
): Promise<unknown> {
- const prefix = message.util.isSlash
- ? '/'
- : client.config.isDevelopment
- ? 'dev '
- : message.util.parsed?.prefix ?? client.config.prefix;
+ const prefix = util.prefix(message);
const row = new MessageActionRow();
if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
@@ -101,8 +93,7 @@ export default class HelpCommand extends BushCommand {
if (command.superUserOnly && !isSuperUser) {
return false;
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
- return !(command.restrictedGuilds?.includes(message.guild?.id!) === false && !args.showHidden);
+ return !(command.restrictedGuilds?.includes(message.guild?.id ?? '') === false && !args.showHidden);
});
const categoryNice = category.id
.replace(/(\b\w)/gi, (lc): string => lc.toUpperCase())
diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts
index 569b959..754b22b 100644
--- a/src/commands/info/links.ts
+++ b/src/commands/info/links.ts
@@ -12,8 +12,6 @@ export default class LinksCommand extends BushCommand {
usage: 'links',
examples: ['links']
},
- ratelimit: 4,
- cooldown: 4000,
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: [],
slash: true
diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts
index 81b3f9d..083acbf 100644
--- a/src/commands/info/snowflake.ts
+++ b/src/commands/info/snowflake.ts
@@ -22,8 +22,6 @@ export default class SnowflakeCommand extends BushCommand {
super('snowflake', {
aliases: ['snowflake', 'info', 'sf'],
category: 'info',
- ratelimit: 4,
- cooldown: 4000,
description: {
content: 'Provides information about the specified Snowflake.',
usage: 'snowflake <snowflake>',
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 353d844..17be687 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -20,8 +20,7 @@ export default class UserInfoCommand extends BushCommand {
start: 'What user would you like to find information about?',
retry: '{error} Choose a valid user to find information about.',
optional: true
- },
- default: null
+ }
}
],
slash: true,