diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-09-07 20:48:15 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-09-07 20:48:15 -0400 |
commit | 15b6988ccffc0a21a570bee7fcb8aabe6ffe08c7 (patch) | |
tree | afd35abcc9baa1964456b3cc6b4602f325a2d161 /src/commands/info/userInfo.ts | |
parent | 048f99752550c6e03d1990a03cad78f3ac7d73aa (diff) | |
download | tanzanite-15b6988ccffc0a21a570bee7fcb8aabe6ffe08c7.tar.gz tanzanite-15b6988ccffc0a21a570bee7fcb8aabe6ffe08c7.tar.bz2 tanzanite-15b6988ccffc0a21a570bee7fcb8aabe6ffe08c7.zip |
fix user command
Diffstat (limited to 'src/commands/info/userInfo.ts')
-rw-r--r-- | src/commands/info/userInfo.ts | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index f70896d..86132c7 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -4,7 +4,6 @@ import { bots, colors, emojis, - formatPerms, mappings, oxford, sleep, @@ -100,14 +99,15 @@ export default class UserInfoCommand extends BotCommand { }); } - // Since discord bald I just guess if someone has nitro + // discord omits nitro information to bots, this is just guessing if ( Number(user.discriminator) < 10 || - mappings.maybeNitroDiscrims.includes(user.discriminator) || - user.displayAvatarURL()?.endsWith('.gif') || + mappings.commonNitroDiscriminators.includes(user.discriminator) || + user.displayAvatarURL()?.endsWith('.gif') || // animated avatars are nitro only user.flags?.has(UserFlags.Partner) || user.flags?.has(UserFlags.Staff) || - member?.avatar // server avatar + member?.avatar || // per server avatars are nitro only + user.banner // banners are nitro only ) { emojis.push(mappings.otherEmojis.Nitro); } @@ -243,14 +243,24 @@ export default class UserInfoCommand extends BotCommand { if (!member) return; // Important Perms - const perms = []; - if (member?.permissions.has(PermissionFlagsBits.Administrator) || member.guild?.ownerId == member.user.id) { - perms.push('`Administrator`'); - } else if (member?.permissions.toArray().length) { - perms.push(formatPerms(member.permissions.toArray().filter((p) => mappings.permissions[p]?.important === true))); + const perms = this.getImportantPermissions(member); + + if (perms.length) embed.addFields({ name: title, value: this.getImportantPermissions(member).join(' ') }); + } + + private static getImportantPermissions(member: GuildMember | undefined) { + if (member == null || member.guild == null) return []; + + if (member.permissions.has('Administrator') || member.guild.ownerId === member.user.id) { + return ['`Administrator`']; } - if (perms.length) embed.addFields({ name: title, value: perms.join(' ') }); + const important = member.permissions + .toArray() + .filter((p) => mappings.permissions[p]?.important === true) + .map((p) => `\`${mappings.permissions[p].name}\``); + + return important; } public static async generateBotField(embed: EmbedBuilder, user: User, title = 'ยป Bot Information') { |