Clean up and improve platform calculation

merge-requests/6/merge
Bsian 2020-06-10 14:28:02 +01:00
parent 1786239f6a
commit e55dcfc7dd
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 9 additions and 10 deletions

View File

@ -65,16 +65,10 @@ export default class Whois extends Command {
break; break;
} }
} }
embed.addField('Status', member.status === 'dnd' ? 'Do Not Disturb' : `${member.status?.substring(0, 1).toUpperCase()}${member.status?.substring(1)}` || 'Unknown', true); embed.addField('Status', member.status === 'dnd' ? 'Do Not Disturb' : this.capsFirstLetter(member.status) || 'Unknown', true);
if (member.bot) { const platform = Object.entries(message.member.clientStatus).filter((a) => a[1] !== 'offline').map((a) => this.capsFirstLetter(a[0]));
embed.addField('Platform', 'API/WebSocket', true); if (member.bot) platform.push('API/WebSocket');
} else if (member.clientStatus?.web === 'online' || member.clientStatus?.web === 'idle' || member.clientStatus?.web === 'dnd') { if (platform.length) embed.addField('Platform', platform.join(', '), true);
embed.addField('Platform', 'Web', true);
} else if (member.clientStatus?.desktop === 'online' || member.clientStatus?.desktop === 'idle' || member.clientStatus?.desktop === 'dnd') {
embed.addField('Platform', 'Desktop', true);
} else if (member.clientStatus?.mobile === 'online' || member.clientStatus?.mobile === 'idle' || member.clientStatus?.mobile === 'dnd') {
embed.addField('Platform', 'Mobile', true);
}
embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
if (member.roles.length > 0) { if (member.roles.length > 0) {
@ -197,4 +191,9 @@ export default class Whois extends Command {
public resolveStaffInformation(id: string) { public resolveStaffInformation(id: string) {
return acknowledgements.find((m) => m.id === id); return acknowledgements.find((m) => m.id === id);
} }
public capsFirstLetter(string?: string): string | void {
if (typeof string !== 'string') return undefined;
return string.substring(0, 1).toUpperCase() + string.substring(1);
}
} }