fix multiple issues with users that have no roles in whois.ts
parent
e1cfd6e3b1
commit
bf56a69aa4
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue