diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 4e7c9b6..47ce288 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -65,16 +65,10 @@ export default class Whois extends Command { break; } } - embed.addField('Status', member.status === 'dnd' ? 'Do Not Disturb' : `${member.status?.substring(0, 1).toUpperCase()}${member.status?.substring(1)}` || 'Unknown', true); - if (member.bot) { - embed.addField('Platform', 'API/WebSocket', true); - } else if (member.clientStatus?.web === 'online' || member.clientStatus?.web === 'idle' || member.clientStatus?.web === 'dnd') { - 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('Status', member.status === 'dnd' ? 'Do Not Disturb' : this.capsFirstLetter(member.status) || 'Unknown', true); + const platform = Object.entries(message.member.clientStatus).filter((a) => a[1] !== 'offline').map((a) => this.capsFirstLetter(a[0])); + if (member.bot) platform.push('API/WebSocket'); + if (platform.length) embed.addField('Platform', platform.join(', '), 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); if (member.roles.length > 0) { @@ -197,4 +191,9 @@ export default class Whois extends Command { public resolveStaffInformation(id: string) { 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); + } }