diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-17 12:31:09 -0400 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-17 12:31:09 -0400 |
| commit | d40527d0a2d9f209905750258f71bedff1cdf089 (patch) | |
| tree | e017fd844c2135bfc85228d00ef2617d24ce0a3f /src/commands/info | |
| parent | d431ad00754f3f250103deedea495b9bcee73fc0 (diff) | |
| download | tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.tar.gz tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.tar.bz2 tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.zip | |
turned on ts strict option
Diffstat (limited to 'src/commands/info')
| -rw-r--r-- | src/commands/info/avatar.ts | 4 | ||||
| -rw-r--r-- | src/commands/info/botInfo.ts | 2 | ||||
| -rw-r--r-- | src/commands/info/color.ts | 4 | ||||
| -rw-r--r-- | src/commands/info/guildInfo.ts | 57 | ||||
| -rw-r--r-- | src/commands/info/help.ts | 13 | ||||
| -rw-r--r-- | src/commands/info/icon.ts | 6 | ||||
| -rw-r--r-- | src/commands/info/invite.ts | 4 | ||||
| -rw-r--r-- | src/commands/info/pronouns.ts | 8 | ||||
| -rw-r--r-- | src/commands/info/snowflakeInfo.ts | 20 | ||||
| -rw-r--r-- | src/commands/info/userInfo.ts | 90 |
10 files changed, 128 insertions, 80 deletions
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index 37d2256..7100afa 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -42,7 +42,9 @@ export default class AvatarCommand extends BushCommand { .setTimestamp() .setColor(util.colors.default) .setTitle(`${user.tag}'s Avatar`) - .setImage(user.avatarURL({ size: 2048, format: 'png', dynamic: true })); + .setImage( + user.avatarURL({ size: 2048, format: 'png', dynamic: true }) ?? 'https://cdn.discordapp.com/embed/avatars/0.png' + ); await message.util.reply({ embeds: [embed] }); } } diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index c89c356..37a63ce 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -24,7 +24,7 @@ export default class BotInfoCommand extends BushCommand { repoUrl = repoUrl.substring(0, repoUrl.length - 4); const embed = new MessageEmbed() .setTitle('Bot Info:') - .addField('**Uptime**', util.humanizeDuration(client.uptime), 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) diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index 93dd439..350c23d 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -1,11 +1,11 @@ import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushRole, BushSlashMessage } from '@lib'; import { Argument } from 'discord-akairo'; -import { MessageEmbed, Role } from 'discord.js'; +import { Message, MessageEmbed, Role } from 'discord.js'; import { Constructor } from 'tinycolor2'; // eslint-disable-next-line @typescript-eslint/no-var-requires const tinycolor: Constructor = require('tinycolor2'); // this is the only way I got it to work consistently -const isValidTinyColor = (_message: BushMessage, phase: string) => { +const isValidTinyColor = (_message: Message, phase: string) => { // if the phase is a number it converts it to hex incase it could be representing a color in decimal const newPhase = Number.isNaN(phase) ? phase : `#${Number(phase).toString(16)}`; return tinycolor(newPhase).isValid() ? newPhase : null; diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 2cdf3d5..431b8bd 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -58,12 +58,16 @@ export default class GuildInfoCommand extends BushCommand { const guild: Guild | GuildPreview = (args?.guild as Guild | GuildPreview) || (message.guild as Guild); const emojis: string[] = []; const guildAbout: string[] = []; - const guildSecurity = []; + 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 (!isPreview && guild instanceof Guild) { - if (guild.premiumTier) emojis.push(client.consts.mappings.otherEmojis['BOOST_' + guild.premiumTier]); + if (guild.premiumTier) + emojis.push( + client.consts.mappings.otherEmojis[('BOOST_' + guild.premiumTier) as keyof typeof client.consts.mappings.otherEmojis] + ); await guild.fetch(); const channelTypes = [ `${client.consts.mappings.otherEmojis.TEXT} ${guild.channels.cache @@ -91,7 +95,7 @@ export default class GuildInfoCommand extends BushCommand { .size.toLocaleString()}` ]; - const guildRegions = []; + const guildRegions: string[] = []; guild.channels.cache.forEach((channel) => { if (!channel.type.includes('VOICE')) return; else if (!guildRegions.includes((channel as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')) { @@ -102,16 +106,16 @@ export default class GuildInfoCommand extends BushCommand { guildAbout.push( `**Owner:** ${guild.members.cache.get(guild.ownerId)?.user.tag}`, `**Created** ${guild.createdAt.toLocaleString()} (${util.dateDelta(guild.createdAt)})`, - `**Members:** ${guild.memberCount.toLocaleString() ?? 0}`, - `**Online:** ${guild.approximatePresenceCount?.toLocaleString() ?? 0}`, - `**Channels:** ${guild.channels.cache.size?.toLocaleString() ?? 0} (${channelTypes.join(', ')})`, - `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0}`, - `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0}`, - `**Regions:** ${guildRegions.map((region) => client.consts.mappings.regions[region] || region).join(', ')}` + `**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(', ')}` ); if (guild.premiumSubscriptionCount) guildAbout.push( - `**Boosts:** Level ${guild.premiumTier == 'NONE' ? '0' : guild.premiumTier[5]} with ${ + `**Boosts:** Level ${guild.premiumTier == 'NONE' ? 0 : guild.premiumTier[5]} with ${ guild.premiumSubscriptionCount ?? 0 } boosts` ); @@ -123,6 +127,28 @@ export default class GuildInfoCommand extends BushCommand { ); } + if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ dynamic: true, size: 4096, format: 'png' })})`); + if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, format: 'png' })})`); + if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, format: 'png' })})`); + + guildStats.push( + `**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`, + // subtract 1 for @everyone role + `**Roles:** ${((guild.roles.cache.size ?? 0) - 1).toLocaleString()} / 250`, + `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0} / ${ + guild.premiumTier === 'TIER_3' + ? 500 + : guild.premiumTier === 'TIER_2' + ? 300 + : guild.premiumTier === 'TIER_1' + ? 100 + : 50 + }`, + `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${ + guild.premiumTier === 'TIER_3' ? 60 : guild.premiumTier === 'TIER_2' ? 30 : guild.premiumTier === 'TIER_1' ? 15 : 0 + }` + ); + guildSecurity.push( `**Verification Level**: ${guild.verificationLevel.toLowerCase().replace(/_/g, ' ')}`, `**Explicit Content Filter:** ${guild.explicitContentFilter.toLowerCase().replace(/_/g, ' ')}`, @@ -135,14 +161,17 @@ export default class GuildInfoCommand extends BushCommand { ); } else { guildAbout.push( - `**Members:** ${guild.approximateMemberCount?.toLocaleString()}`, - `**Online:** ${guild.approximatePresenceCount?.toLocaleString()}`, + `**Members:** ${guild.approximateMemberCount?.toLocaleString() ?? 0} (${util.emojis.onlineCircle} ${ + guild.approximatePresenceCount?.toLocaleString() ?? 0 + }, ${util.emojis.offlineCircle} ${( + (guild.approximateMemberCount ?? 0) - (guild.approximatePresenceCount ?? 0) + ).toLocaleString()})`, `**Emojis:** ${(guild as GuildPreview).emojis.size?.toLocaleString() ?? 0}` // `**Stickers:** ${(guild as GuildPreview).stickers.size}` ); } - const guildFeatures = guild.features.sort((a, b) => { + const guildFeatures = guild.features.sort((a, b): number => { const aWeight = client.consts.mappings.features[a]?.weight; const bWeight = client.consts.mappings.features[b]?.weight; @@ -153,6 +182,7 @@ export default class GuildInfoCommand extends BushCommand { } else if (bWeight == undefined) { return -1; } + return 0; }); if (guildFeatures.length) { guildFeatures.forEach((feature) => { @@ -174,6 +204,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')); const guildIcon = guild.iconURL({ size: 2048, format: 'png', dynamic: true }); if (guildIcon) { guildInfoEmbed.setThumbnail(guildIcon); diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 691051c..97811da 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -47,7 +47,7 @@ export default class HelpCommand extends BushCommand { message: BushMessage | BushSlashMessage, args: { command: BushCommand | string; showHidden?: boolean } ): Promise<unknown> { - const prefix = client.config.isDevelopment ? 'dev ' : message.util.parsed.prefix; + const prefix = client.config.isDevelopment ? 'dev ' : message.util.parsed?.prefix ?? client.config.prefix; const row = new MessageActionRow(); if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { @@ -55,11 +55,13 @@ export default class HelpCommand extends BushCommand { new MessageButton({ style: 'LINK', label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${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 (!client.guilds.cache.get(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', @@ -80,7 +82,7 @@ export default class HelpCommand extends BushCommand { const isSuperUser = client.isSuperUser(message.author); const command = args.command ? typeof args.command === 'string' - ? client.commandHandler.modules.get(args.command) || null + ? client.commandHandler.modules.get(args.command) ?? null : args.command : null; if (!isOwner) args.showHidden = false; @@ -98,7 +100,8 @@ export default class HelpCommand extends BushCommand { if (command.superUserOnly && !isSuperUser) { return false; } - return !(command.restrictedGuilds?.includes(message.guild.id) === false && !args.showHidden); + // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain + 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/icon.ts b/src/commands/info/icon.ts index 582494c..677fdaf 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -22,13 +22,13 @@ export default class IconCommand extends BushCommand { .setTimestamp() .setColor(util.colors.default) .setImage( - message.guild?.iconURL({ + message.guild!.iconURL({ size: 2048, dynamic: true, format: 'png' - }) + })! ) - .setTitle(message.guild.name); + .setTitle(message.guild!.name); await message.util.reply({ embeds: [embed] }); } } diff --git a/src/commands/info/invite.ts b/src/commands/info/invite.ts index 384c59e..615e767 100644 --- a/src/commands/info/invite.ts +++ b/src/commands/info/invite.ts @@ -24,7 +24,9 @@ export default class InviteCommand extends BushCommand { new MessageButton({ style: 'LINK', label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${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/pronouns.ts b/src/commands/info/pronouns.ts index 6f2b074..c7eac7f 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,5 +1,5 @@ -import { BushCommand, BushSlashMessage } from '@lib'; -import { Message, MessageEmbed, User } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; +import { MessageEmbed, User } from 'discord.js'; import got, { HTTPError } from 'got'; export const pronounMapping = { @@ -60,8 +60,8 @@ export default class PronounsCommand extends BushCommand { slash: true }); } - override async exec(message: Message | BushSlashMessage, args: { user?: User }): Promise<unknown> { - const user = args.user || message.author; + override async exec(message: BushMessage | BushSlashMessage, args: { user?: User }): Promise<unknown> { + const user = args.user ?? message.author; const author = user.id === message.author.id; try { const apiRes: { pronouns: pronounsType } = await got diff --git a/src/commands/info/snowflakeInfo.ts b/src/commands/info/snowflakeInfo.ts index f293219..c4d71da 100644 --- a/src/commands/info/snowflakeInfo.ts +++ b/src/commands/info/snowflakeInfo.ts @@ -58,7 +58,7 @@ export default class SnowflakeInfoCommand extends BushCommand { // Channel if (client.channels.cache.has(snowflake)) { - const channel: Channel = client.channels.cache.get(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; @@ -89,38 +89,38 @@ export default class SnowflakeInfoCommand extends BushCommand { // Guild else if (client.guilds.cache.has(snowflake)) { - const guild: Guild = client.guilds.cache.get(snowflake); + const guild: Guild = client.guilds.cache.get(snowflake)!; const guildInfo = [ `**Name:** ${guild.name}`, - `**Owner:** ${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 })); + if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!); snowflakeEmbed.addField('» Server Info', guildInfo.join('\n')); snowflakeEmbed.setTitle(`:snowflake: ${guild.name} \`[Server]\``); } // User else if (client.users.cache.has(snowflake)) { - const user: User = client.users.cache.get(snowflake); + const user: User = client.users.cache.get(snowflake)!; const userInfo = [`**Name:** <@${user.id}> (${user.tag})`]; - snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })); + if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })!); snowflakeEmbed.addField('» User Info', userInfo.join('\n')); snowflakeEmbed.setTitle(`:snowflake: ${user.tag} \`[User]\``); } // Emoji else if (client.emojis.cache.has(snowflake)) { - const emoji: Emoji = client.emojis.cache.get(snowflake); + const emoji: Emoji = client.emojis.cache.get(snowflake)!; const emojiInfo = [`**Name:** ${emoji.name}`, `**Animated:** ${emoji.animated}`]; - snowflakeEmbed.setThumbnail(emoji.url); + if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n')); snowflakeEmbed.setTitle(`:snowflake: ${emoji.name} \`[Emoji]\``); } // Role - else if (message.guild.roles.cache.has(snowflake)) { - const role: Role = message.guild.roles.cache.get(snowflake); + else if (message.guild && message.guild.roles.cache.has(snowflake)) { + const role: Role = message.guild.roles.cache.get(snowflake)!; const roleInfo = [ `**Name:** <@&${role.id}> (${role.name})`, `**Members:** ${role.members.size}`, diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index d9922d0..9ec5552 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -1,7 +1,6 @@ -import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { GuildMember, MessageEmbed } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; +import { MessageEmbed } from 'discord.js'; -// TODO: Allow looking up a user not in the guild and not cached (if possible) // TODO: Re-Implement Status Emojis // TODO: Add bot information export default class UserInfoCommand extends BushCommand { @@ -17,7 +16,7 @@ export default class UserInfoCommand extends BushCommand { args: [ { id: 'user', - type: 'member', + customType: util.arg.union('user', 'bigint'), prompt: { start: 'What user would you like to find information about?', retry: '{error} Choose a valid user to find information about.', @@ -40,48 +39,57 @@ export default class UserInfoCommand extends BushCommand { }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { user: GuildMember }): Promise<unknown> { - const user = args?.user || message.member; + public override async exec(message: BushMessage | BushSlashMessage, args: { user: BushUser | bigint }): Promise<unknown> { + const user = + args?.user === undefined || args?.user === null + ? message.author + : typeof args.user === 'object' + ? args.user + : await client.users.fetch(`${args.user}`).catch(() => undefined); + if (user === undefined) return message.util.reply(`${util.emojis.error} Invalid user.`); + const member = message.guild ? message.guild.members.cache.get(user.id) : undefined; const emojis = []; const superUsers = client.cache.global.superUsers; const userEmbed: MessageEmbed = new MessageEmbed() - .setTitle(user.user.tag) - .setThumbnail(user.user.avatarURL({ size: 2048, format: 'png', dynamic: true })) + .setTitle(user.tag) + .setThumbnail( + user.avatarURL({ size: 2048, format: 'png', dynamic: true }) ?? 'https://cdn.discordapp.com/embed/avatars/0.png' + ) .setTimestamp(); // Flags 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(); + const flags = user.flags?.toArray(); if (flags) { flags.forEach((f) => { if (client.consts.mappings.userFlags[f]) { emojis.push(client.consts.mappings.userFlags[f]); - } else emojis.push(f); + } else emojis.push(`\`${f}\``); }); } // Since discord bald I just guess if someone has nitro if ( - Number(user.user.discriminator) < 10 || - client.consts.mappings.maybeNitroDiscrims.includes(user.user.discriminator) || - user.user.displayAvatarURL({ dynamic: true })?.endsWith('.gif') || - user.user.flags?.toArray().includes('PARTNERED_SERVER_OWNER') + Number(user.discriminator) < 10 || + client.consts.mappings.maybeNitroDiscrims.includes(user.discriminator) || + user.displayAvatarURL({ dynamic: true })?.endsWith('.gif') || + user.flags?.toArray().includes('PARTNERED_SERVER_OWNER') ) { emojis.push(client.consts.mappings.otherEmojis.NITRO); } - 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); + if (message.guild?.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.OWNER); + else if (member?.permissions.has('ADMINISTRATOR')) emojis.push(client.consts.mappings.otherEmojis.ADMIN); + if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.BOOSTER); - const createdAt = user.user.createdAt.toLocaleString(), - createdAtDelta = util.dateDelta(user.user.createdAt), - joinedAt = user.joinedAt?.toLocaleString(), - joinedAtDelta = util.dateDelta(user.joinedAt, 2), - premiumSince = user.premiumSince?.toLocaleString(), - premiumSinceDelta = util.dateDelta(user.premiumSince, 2); + const createdAt = user.createdAt.toLocaleString(), + createdAtDelta = util.dateDelta(user.createdAt), + joinedAt = member?.joinedAt?.toLocaleString(), + joinedAtDelta = member && member.joinedAt ? util.dateDelta(member.joinedAt, 2) : undefined, + premiumSince = member?.premiumSince?.toLocaleString(), + premiumSinceDelta = member && member.premiumSince ? util.dateDelta(member.premiumSince, 2) : undefined; // General Info const generalInfo = [ @@ -95,27 +103,27 @@ export default class UserInfoCommand extends BushCommand { const serverUserInfo = []; if (joinedAt) serverUserInfo.push( - `**${message.guild.ownerId == user.id ? 'Created Server' : 'Joined'}: ** ${joinedAt} (${joinedAtDelta} ago)` + `**${message.guild!.ownerId == user.id ? 'Created Server' : 'Joined'}: ** ${joinedAt} (${joinedAtDelta} ago)` ); 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 == client.consts.mappings.guilds.bush) + if (member?.displayHexColor) serverUserInfo.push(`**Display Color:** ${member.displayHexColor}`); + if (user.id == '322862723090219008' && message.guild?.id == client.consts.mappings.guilds.bush) serverUserInfo.push(`**General Deletions:** 1⅓`); if ( ['384620942577369088', '496409778822709251'].includes(user.id) && - message.guild.id == client.consts.mappings.guilds.bush + message.guild?.id == client.consts.mappings.guilds.bush ) serverUserInfo.push(`**General Deletions:** ⅓`); - if (user.nickname) serverUserInfo.push(`**Nickname** ${user.nickname}`); + if (member?.nickname) serverUserInfo.push(`**Nickname** ${member?.nickname}`); if (serverUserInfo.length) - userEmbed.addField('» Server Info', serverUserInfo.join('\n')).setColor(user.displayColor || util.colors.default); + userEmbed.addField('» Server Info', serverUserInfo.join('\n')).setColor(member?.displayColor ?? util.colors.default); // User Presence Info - if (user.presence?.status || user.presence?.clientStatus || user.presence?.activities) { + if (member?.presence?.status || member?.presence?.clientStatus || member?.presence?.activities) { let customStatus = ''; - const activitiesNames = []; - if (user.presence.activities) { - user.presence.activities.forEach((a) => { + const activitiesNames: string[] = []; + if (member.presence.activities) { + member.presence.activities.forEach((a) => { if (a.type == 'CUSTOM' && a.state) { const emoji = `${a.emoji ? `${a.emoji.toString()} ` : ''}`; customStatus = `${emoji}${a.state}`; @@ -124,9 +132,9 @@ export default class UserInfoCommand extends BushCommand { }); } let devices; - if (user.presence.clientStatus) devices = Object.keys(user.presence.clientStatus); + if (member?.presence.clientStatus) devices = Object.keys(member.presence.clientStatus); const presenceInfo = []; - if (user.presence.status) presenceInfo.push(`**Status:** ${user.presence.status}`); + if (member?.presence.status) presenceInfo.push(`**Status:** ${member.presence.status}`); if (devices && devices.length) presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${util.oxford(devices, 'and', '')}`); if (activitiesNames.length) @@ -137,12 +145,14 @@ export default class UserInfoCommand extends BushCommand { // Important Perms const perms = []; - if (user.permissions.has('ADMINISTRATOR') || message.guild.ownerId == user.id) { + if (member?.permissions.has('ADMINISTRATOR') || message.guild?.ownerId == user.id) { perms.push('`Administrator`'); - } else { - user.permissions.toArray(true).forEach((permission) => { - if (client.consts.mappings.permissions[permission]?.important) { - perms.push(`\`${client.consts.mappings.permissions[permission].name}\``); + } else if (member?.permissions.toArray(true).length) { + member.permissions.toArray(true).forEach((permission) => { + if (client.consts.mappings.permissions[permission as keyof typeof client.consts.mappings.permissions]?.important) { + perms.push( + `\`${client.consts.mappings.permissions[permission as keyof typeof client.consts.mappings.permissions].name}\`` + ); } }); } |
