diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-26 18:47:13 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-26 18:47:13 -0400 |
commit | 80d5b5b11ae261945dc725a0a80115922003afcf (patch) | |
tree | 16c9f251b4d53456b4b5340c0203d35fd5870859 /src/commands/info | |
parent | cca0b7a03bcd61af12b7f9bff51276f6c70beeb3 (diff) | |
download | tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.tar.gz tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.tar.bz2 tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.zip |
refactor: this.client -> client
Diffstat (limited to 'src/commands/info')
-rw-r--r-- | src/commands/info/botInfo.ts | 16 | ||||
-rw-r--r-- | src/commands/info/guildInfo.ts | 32 | ||||
-rw-r--r-- | src/commands/info/help.ts | 16 | ||||
-rw-r--r-- | src/commands/info/invite.ts | 5 | ||||
-rw-r--r-- | src/commands/info/ping.ts | 2 | ||||
-rw-r--r-- | src/commands/info/snowflakeInfo.ts | 18 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 28 |
7 files changed, 58 insertions, 59 deletions
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 29ed29a..e47984b 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -18,21 +18,21 @@ export default class BotInfoCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage): Promise<void> { - const developers = (await util.mapIDs(this.client.config.owners)).map((u) => u?.tag).join('\n'); + const developers = (await util.mapIDs(client.config.owners)).map((u) => u?.tag).join('\n'); const currentCommit = (await util.shell('git rev-parse HEAD')).stdout.replace('\n', ''); let repoUrl = (await util.shell('git remote get-url origin')).stdout.replace('\n', ''); repoUrl = repoUrl.substring(0, repoUrl.length - 4); const embed = new MessageEmbed() .setTitle('Bot Info:') - .addField('**Uptime**', util.humanizeDuration(this.client.uptime), true) - .addField('**Servers**', this.client.guilds.cache.size.toLocaleString(), true) - .addField('**Users**', this.client.users.cache.size.toLocaleString(), true) + .addField('**Uptime**', util.humanizeDuration(client.uptime), true) + .addField('**Servers**', client.guilds.cache.size.toLocaleString(), true) + .addField('**Users**', client.users.cache.size.toLocaleString(), true) .addField('**Discord.js Version**', discordJSVersion, true) .addField('**Node.js Version**', process.version.slice(1), true) - .addField('**Commands**', this.client.commandHandler.modules.size.toLocaleString(), true) - .addField('**Listeners**', this.client.listenerHandler.modules.size.toLocaleString(), true) - .addField('**Inhibitors**', this.client.inhibitorHandler.modules.size.toLocaleString(), true) - .addField('**Tasks**', this.client.taskHandler.modules.size.toLocaleString(), true) + .addField('**Commands**', client.commandHandler.modules.size.toLocaleString(), true) + .addField('**Listeners**', client.listenerHandler.modules.size.toLocaleString(), true) + .addField('**Inhibitors**', client.inhibitorHandler.modules.size.toLocaleString(), true) + .addField('**Tasks**', client.taskHandler.modules.size.toLocaleString(), true) .addField('**Current Commit**', `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})`, true) .addField('**Developers**', developers, true) .setTimestamp() diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 2e541f3..e82a5fe 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -47,7 +47,7 @@ export default class GuildInfoCommand extends BushCommand { } let isPreview = false; if (['bigint', 'number', 'string'].includes(typeof args?.guild)) { - const preview = await this.client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {}); + const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {}); if (preview) { args.guild = preview; isPreview = true; @@ -60,31 +60,31 @@ export default class GuildInfoCommand extends BushCommand { const guildAbout: string[] = []; // const guildSecurity = []; if (['516977525906341928', '784597260465995796', '717176538717749358', '767448775450820639'].includes(guild.id)) - emojis.push(this.client.consts.mappings.otherEmojis.BUSH_VERIFIED); + emojis.push(client.consts.mappings.otherEmojis.BUSH_VERIFIED); if (!isPreview && guild instanceof Guild) { - if (guild.premiumTier) emojis.push(this.client.consts.mappings.otherEmojis['BOOST_' + guild.premiumTier]); + if (guild.premiumTier) emojis.push(client.consts.mappings.otherEmojis['BOOST_' + guild.premiumTier]); await guild.fetch(); const channelTypes = [ - `${this.client.consts.mappings.otherEmojis.TEXT} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.TEXT} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_TEXT') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.NEWS} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.NEWS} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_NEWS') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.VOICE} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.VOICE} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_VOICE') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.STAGE} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.STAGE} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_STAGE_VOICE') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.STORE} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.STORE} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_STORE') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.CATEGORY} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.CATEGORY} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_CATEGORY') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.THREAD} ${guild.channels.cache + `${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) ) @@ -125,8 +125,8 @@ export default class GuildInfoCommand extends BushCommand { } const guildFeatures = guild.features.sort((a, b) => { - const aWeight = this.client.consts.mappings.features[a]?.weight; - const bWeight = this.client.consts.mappings.features[b]?.weight; + const aWeight = client.consts.mappings.features[a]?.weight; + const bWeight = client.consts.mappings.features[b]?.weight; if (aWeight != undefined && bWeight != undefined) { return aWeight - bWeight; @@ -138,10 +138,10 @@ export default class GuildInfoCommand extends BushCommand { }); if (guildFeatures.length) { guildFeatures.forEach((feature) => { - if (this.client.consts.mappings.features[feature]?.emoji) { - emojis.push(`${this.client.consts.mappings.features[feature].emoji}`); - } else if (this.client.consts.mappings.features[feature]?.name) { - emojis.push(`\`${this.client.consts.mappings.features[feature].name}\``); + 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}\``); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index a644755..458b7d0 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -47,24 +47,24 @@ export default class HelpCommand extends BushCommand { message: BushMessage | BushSlashMessage, args: { command: BushCommand | string; showHidden?: boolean } ): Promise<unknown> { - const prefix = this.client.config.isDevelopment ? 'dev ' : message.util.parsed.prefix; + const prefix = client.config.isDevelopment ? 'dev ' : message.util.parsed.prefix; const row = new MessageActionRow(); - if (!this.client.config.isDevelopment && !this.client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { + if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { row.addComponents( new MessageButton({ style: 'LINK', label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${this.client.user.id}&permissions=2147483647&scope=bot%20applications.commands` + url: `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=2147483647&scope=bot%20applications.commands` }) ); } - if (!this.client.guilds.cache.get(this.client.config.supportGuild.id).members.cache.has(message.author.id)) { + if (!client.guilds.cache.get(client.config.supportGuild.id).members.cache.has(message.author.id)) { row.addComponents( new MessageButton({ style: 'LINK', label: 'Support Server', - url: this.client.config.supportGuild.invite + url: client.config.supportGuild.invite }) ); } @@ -76,11 +76,11 @@ export default class HelpCommand extends BushCommand { }) ); - const isOwner = this.client.isOwner(message.author); - const isSuperUser = this.client.isSuperUser(message.author); + const isOwner = client.isOwner(message.author); + const isSuperUser = client.isSuperUser(message.author); const command = args.command ? typeof args.command === 'string' - ? this.client.commandHandler.modules.get(args.command) || null + ? client.commandHandler.modules.get(args.command) || null : args.command : null; if (!isOwner) args.showHidden = false; diff --git a/src/commands/info/invite.ts b/src/commands/info/invite.ts index 1f65cdc..a2128b3 100644 --- a/src/commands/info/invite.ts +++ b/src/commands/info/invite.ts @@ -19,13 +19,12 @@ export default class InviteCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { - if (this.client.config.isDevelopment) - return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`); + if (client.config.isDevelopment) return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`); const ButtonRow = new MessageActionRow().addComponents( new MessageButton({ style: 'LINK', label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${this.client.user.id}&permissions=2147483647&scope=bot%20applications.commands` + url: `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=2147483647&scope=bot%20applications.commands` }) ); return await message.util.reply({ content: 'You can invite me here:', components: [ButtonRow] }); diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 36f3bc7..550c3c7 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -40,7 +40,7 @@ export default class PingCommand extends BushCommand { await message.interaction.reply('Pong!'); const timestamp2 = await message.interaction.fetchReply().then((m) => (m as Message).createdTimestamp); const botLatency = `${'```'}\n ${Math.round(timestamp2 - timestamp1)}ms ${'```'}`; - const apiLatency = `${'```'}\n ${Math.round(this.client.ws.ping)}ms ${'```'}`; + const apiLatency = `${'```'}\n ${Math.round(client.ws.ping)}ms ${'```'}`; const embed = new MessageEmbed() .setTitle('Pong! 🏓') .addField('Bot Latency', botLatency, true) diff --git a/src/commands/info/snowflakeInfo.ts b/src/commands/info/snowflakeInfo.ts index b32245c..b6b9e16 100644 --- a/src/commands/info/snowflakeInfo.ts +++ b/src/commands/info/snowflakeInfo.ts @@ -57,8 +57,8 @@ export default class SnowflakeInfoCommand extends BushCommand { const snowflakeEmbed = new MessageEmbed().setTitle('Unknown :snowflake:').setColor(util.colors.default); // Channel - if (this.client.channels.cache.has(snowflake)) { - const channel: Channel = this.client.channels.cache.get(snowflake); + if (client.channels.cache.has(snowflake)) { + const channel: Channel = client.channels.cache.get(snowflake); const channelInfo = [`**Type:** ${channel.type}`]; if (['dm', 'group'].includes(channel.type)) { const _channel = channel as DMChannel; @@ -88,11 +88,11 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Guild - else if (this.client.guilds.cache.has(snowflake)) { - const guild: Guild = this.client.guilds.cache.get(snowflake); + else if (client.guilds.cache.has(snowflake)) { + const guild: Guild = client.guilds.cache.get(snowflake); const guildInfo = [ `**Name:** ${guild.name}`, - `**Owner:** ${this.client.users.cache.get(guild.ownerId)?.tag || '¯\\_(ツ)_/¯'} (${guild.ownerId})`, + `**Owner:** ${client.users.cache.get(guild.ownerId)?.tag || '¯\\_(ツ)_/¯'} (${guild.ownerId})`, `**Members:** ${guild.memberCount?.toLocaleString()}` ]; snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })); @@ -101,8 +101,8 @@ export default class SnowflakeInfoCommand extends BushCommand { } // User - else if (this.client.users.cache.has(snowflake)) { - const user: User = this.client.users.cache.get(snowflake); + else if (client.users.cache.has(snowflake)) { + const user: User = client.users.cache.get(snowflake); const userInfo = [`**Name:** <@${user.id}> (${user.tag})`]; snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })); snowflakeEmbed.addField('» User Info', userInfo.join('\n')); @@ -110,8 +110,8 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Emoji - else if (this.client.emojis.cache.has(snowflake)) { - const emoji: Emoji = this.client.emojis.cache.get(snowflake); + else if (client.emojis.cache.has(snowflake)) { + const emoji: Emoji = client.emojis.cache.get(snowflake); const emojiInfo = [`**Name:** ${emoji.name}`, `**Animated:** ${emoji.animated}`]; snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n')); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 5cfc6f0..87235a9 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -44,7 +44,7 @@ export default class UserInfoCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, args: { user: GuildMember }): Promise<unknown> { const user = args?.user || message.member; const emojis = []; - const superUsers = this.client.cache.global.superUsers; + const superUsers = client.cache.global.superUsers; const userEmbed: MessageEmbed = new MessageEmbed() .setTitle(user.user.tag) @@ -52,13 +52,13 @@ export default class UserInfoCommand extends BushCommand { .setTimestamp(); // Flags - if (this.client.config.owners.includes(user.id)) emojis.push(this.client.consts.mappings.otherEmojis.DEVELOPER); - if (superUsers.includes(user.id)) emojis.push(this.client.consts.mappings.otherEmojis.SUPERUSER); + if (client.config.owners.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.DEVELOPER); + if (superUsers.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.SUPERUSER); const flags = user.user.flags?.toArray(); if (flags) { flags.forEach((f) => { - if (this.client.consts.mappings.userFlags[f]) { - emojis.push(this.client.consts.mappings.userFlags[f]); + if (client.consts.mappings.userFlags[f]) { + emojis.push(client.consts.mappings.userFlags[f]); } else emojis.push(f); }); } @@ -66,16 +66,16 @@ export default class UserInfoCommand extends BushCommand { // Since discord bald I just guess if someone has nitro if ( Number(user.user.discriminator) < 10 || - this.client.consts.mappings.maybeNitroDiscrims.includes(user.user.discriminator) || + client.consts.mappings.maybeNitroDiscrims.includes(user.user.discriminator) || user.user.displayAvatarURL({ dynamic: true })?.endsWith('.gif') || user.user.flags?.toArray().includes('PARTNERED_SERVER_OWNER') ) { - emojis.push(this.client.consts.mappings.otherEmojis.NITRO); + emojis.push(client.consts.mappings.otherEmojis.NITRO); } - if (message.guild.ownerId == user.id) emojis.push(this.client.consts.mappings.otherEmojis.OWNER); - else if (user.permissions.has('ADMINISTRATOR')) emojis.push(this.client.consts.mappings.otherEmojis.ADMIN); - if (user.premiumSinceTimestamp) emojis.push(this.client.consts.mappings.otherEmojis.BOOSTER); + if (message.guild.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.OWNER); + else if (user.permissions.has('ADMINISTRATOR')) emojis.push(client.consts.mappings.otherEmojis.ADMIN); + if (user.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.BOOSTER); const createdAt = user.user.createdAt.toLocaleString(), createdAtDelta = moment(moment(user.user.createdAt).diff(moment())).toLocaleString(), @@ -100,11 +100,11 @@ export default class UserInfoCommand extends BushCommand { ); if (premiumSince) serverUserInfo.push(`**Boosting Since:** ${premiumSince} (${premiumSinceDelta} ago)`); if (user.displayHexColor) serverUserInfo.push(`**Display Color:** ${user.displayHexColor}`); - if (user.id == '322862723090219008' && message.guild.id == this.client.consts.mappings.guilds.bush) + if (user.id == '322862723090219008' && message.guild.id == client.consts.mappings.guilds.bush) serverUserInfo.push(`**General Deletions:** 2`); if ( ['384620942577369088', '496409778822709251'].includes(user.id) && - message.guild.id == this.client.consts.mappings.guilds.bush + message.guild.id == client.consts.mappings.guilds.bush ) serverUserInfo.push(`**General Deletions:** 1`); if (user.nickname) serverUserInfo.push(`**Nickname** ${user.nickname}`); @@ -141,8 +141,8 @@ export default class UserInfoCommand extends BushCommand { perms.push('`Administrator`'); } else { user.permissions.toArray(true).forEach((permission) => { - if (this.client.consts.mappings.permissions[permission]?.important) { - perms.push(`\`${this.client.consts.mappings.permissions[permission].name}\``); + if (client.consts.mappings.permissions[permission]?.important) { + perms.push(`\`${client.consts.mappings.permissions[permission].name}\``); } }); } |