From 15b6988ccffc0a21a570bee7fcb8aabe6ffe08c7 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 7 Sep 2022 20:48:15 -0400 Subject: fix user command --- src/commands/info/userInfo.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/commands/info/userInfo.ts') 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') { -- cgit