From 6278ba68210a556303952839e3695b2cfce246bf Mon Sep 17 00:00:00 2001 From: Bsian Date: Thu, 21 May 2020 07:28:04 +0100 Subject: [PATCH] Clean up optional chaining --- src/commands/delitem.ts | 4 ++-- src/commands/whois.ts | 30 ++++++++++++++---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/commands/delitem.ts b/src/commands/delitem.ts index 813ba36..164a3af 100644 --- a/src/commands/delitem.ts +++ b/src/commands/delitem.ts @@ -24,7 +24,7 @@ export default class DelItem extends Command { } if (args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(args[0].split('-')[1])) { const account = await this.client.db.Member.findOne({ userID: message.member.id }); - if (!account || !account?.additional.operatingSystems || account?.additional.operatingSystems.length < 1) { + if (account?.additional.operatingSystems.length < 1) { return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any operating systems to remove.***`); } await account.updateOne({ $pull: { 'additional.operatingSystems': args[0].split('-')[1] } }); @@ -32,7 +32,7 @@ export default class DelItem extends Command { } if (args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(args[0].split('-')[1])) { const account = await this.client.db.Member.findOne({ userID: message.member.id }); - if (!account || !account?.additional.langs || account?.additional.langs.length < 1) { + if (account?.additional.langs.length < 1) { return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any languages to remove.***`); } await account.updateOne({ $pull: { 'additional.langs': args[0].split('-')[1] } }); diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 45591a2..f578bd3 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -41,22 +41,20 @@ export default class Whois extends Command { embed.setThumbnail(member.avatarURL); const ackResolve = this.resolveStaffInformation(member.id); let description = ''; - if (ackResolve) { - if (ackResolve?.title) { - description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__\n\n`; - } - if (ackResolve?.emailAddress) { - description += `${emotes.email} ${ackResolve.emailAddress}\n`; - } - if (ackResolve?.gitlab) { - description += `${emotes.gitlab} ${ackResolve.gitlab}\n`; - } - if (ackResolve?.github) { - description += `${emotes.github} ${ackResolve.github}\n`; - } - if (ackResolve?.bio) { - description += `${emotes.bio} *${ackResolve.bio}*\n`; - } + if (ackResolve?.title) { + description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__\n\n`; + } + if (ackResolve?.emailAddress) { + description += `${emotes.email} ${ackResolve.emailAddress}\n`; + } + if (ackResolve?.gitlab) { + description += `${emotes.gitlab} ${ackResolve.gitlab}\n`; + } + if (ackResolve?.github) { + description += `${emotes.github} ${ackResolve.github}\n`; + } + if (ackResolve?.bio) { + description += `${emotes.bio} *${ackResolve.bio}*\n`; } description += `\n<@${member.id}>`; embed.setDescription(description);