fix multiple issues with users that have no roles in whois.ts

merge-requests/7/head
Matthew 2020-04-17 12:44:17 -04:00
parent e1cfd6e3b1
commit bf56a69aa4
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 9 additions and 5 deletions

View File

@ -61,14 +61,18 @@ export default class Whois extends Command {
description += `\n<@${member.id}>`; description += `\n<@${member.id}>`;
embed.setDescription(description); 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); 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) {
const { color } = roles.find((r) => r.color); embed.setColor(role.color);
embed.setColor(color); break;
}
}
embed.addField('Status', `${member.status[0].toUpperCase()}${member.status.slice(1)}`, true); 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('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('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 permissions: string[] = [];
const serverAcknowledgements: string[] = []; const serverAcknowledgements: string[] = [];
const bit = member.permission.allow; const bit = member.permission.allow;