userinfo: oop

This commit is contained in:
Cynthia Foxwell 2025-05-18 14:25:27 -06:00
parent 29f381b18a
commit 2fca9ed7a8
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -306,7 +306,8 @@ userinfo.callback = async function (msg, line) {
descLines.push("**System account**");
}
const primaryGuild = await getGuild(user.primary_guild.identity_guild_id);
let primaryGuild;
if (user.primary_guild?.identity_guild_id) primaryGuild = await getGuild(user.primary_guild.identity_guild_id);
if (anyMember) {
const icons = [];
@ -393,11 +394,11 @@ userinfo.callback = async function (msg, line) {
inline: true,
},
member?.roles?.length > 0 && {
name: "Roles",
name: `Roles (${member.roles.length})`,
value: member.roles
.sort((a, b) => guild.roles.get(b).position - guild.roles.get(a).position)
.map((role) => `<@&${role}>`)
.join(", "),
.join(" "),
inline: false,
},
shared.length > 0 && {
@ -408,7 +409,7 @@ userinfo.callback = async function (msg, line) {
images.length > 0 && {
name: "\u200b",
value: images.join("\u3000"),
inline: true,
inline: false,
},
].filter((x) => !!x),
footer: {
@ -416,14 +417,6 @@ userinfo.callback = async function (msg, line) {
},
};
if (embed.fields.length == 2) {
// assumed created + images
embed.fields[1].inline = false;
} else if (embed.fields.length == 3) {
// assumed created + clan + images
embed.fields[2].inline = false;
}
return {embeds: [embed]};
};
hf.registerCommand(userinfo);