Skip to content

Commit

Permalink
fix: user info (#72)
Browse files Browse the repository at this point in the history
* fix: user info
- Doesn't show discrim on pomelo usernames
- Doesn't show aka when no nick
- Fix crash with no roles
- Doesn't show badge bitfield values

Note: Display names are currently not possible, do to lack of d.js support.
When this change is pushed, we can also remove the tag check.

I also enabled source maps on run cause it was annoying me

* chore: prettify
  • Loading branch information
WilsontheWolf authored Jun 20, 2023
1 parent 648b522 commit 94e46b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"prettify": "eslint ./src/ --fix && npx prettier -w .",
"build": "tsc -p tsconfig.json",
"run": "node --experimental-specifier-resolution=node .",
"run": "node --experimental-specifier-resolution=node --enable-source-maps .",
"start": "npm run build && npm run run",
"prepare": "husky install"
},
Expand Down
10 changes: 5 additions & 5 deletions src/commands/UserInfoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ const badges = {
function getUserEmbed(user: User, member: GuildMember | null | undefined): EmbedBuilder {
const embed = new EmbedBuilder()
.setTitle(
`${user.tag} ${member ? "aka. " + member.displayName : ""} ${
user.system ? "| System" : user.bot ? "| Bot" : ""
}`
`${user.discriminator === "0" ? user.username : user.tag}${
member?.nickname ? " aka. " + member.nickname : ""
} ${user.system ? "| System" : user.bot ? "| Bot" : ""}`
)
.setThumbnail(user.displayAvatarURL({ size: 1024, extension: "png" }))
.setDescription(user.toString());
Expand Down Expand Up @@ -95,12 +95,12 @@ function getUserEmbed(user: User, member: GuildMember | null | undefined): Embed
name: "Discord Badges",
value: user.flags
.toArray()
.filter((v) => !v.match(/^\d+$/))
.map((v) => badges[v as keyof typeof badges] || v.replace(/[A-Z0-9]/g, " $&").trim())
.join(", "),
});
}

embed.addFields({ name: "Roles", value: roles });
if (roles) embed.addFields({ name: "Roles", value: roles });
}
return addEmbedFooter(embed);
}
Expand Down

0 comments on commit 94e46b2

Please sign in to comment.