diff --git a/src/commands/whois.ts b/src/commands/whois.ts index dcd2d76..4f47c4d 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -61,14 +61,18 @@ export default class Whois extends Command { description += `\n<@${member.id}>`; embed.setDescription(description); - const roles = member.roles.map((r) => this.client.guilds.get(this.client.config.guildID).roles.get(r)).sort((a, b) => b.position - a.position); - - const { color } = roles.find((r) => r.color); - embed.setColor(color); + for (const role of member.roles.map((r) => this.client.guilds.get(this.client.config.guildID).roles.get(r)).sort((a, b) => b.position - a.position)) { + if (role?.color !== 0) { + embed.setColor(role.color); + break; + } + } embed.addField('Status', `${member.status[0].toUpperCase()}${member.status.slice(1)}`, true); embed.addField('Joined At', `${moment(new Date(message.member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); embed.addField('Created At', `${moment(new Date(message.author.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); - embed.addField(`Roles [${roles.length}]`, roles.map((r) => `<@&${r.id}>`).join(', ')); + if (message.member.roles.length > 0) { + embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => this.client.guilds.get(this.client.config.guildID).roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', ')); + } const permissions: string[] = []; const serverAcknowledgements: string[] = []; const bit = member.permission.allow;