Clean up optional chaining

merge-requests/12/merge
Bsian 2020-05-21 07:28:04 +01:00
parent 2656df909b
commit 6278ba6821
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 16 additions and 18 deletions

View File

@ -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])) { 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 }); 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.***`); 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] } }); 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])) { 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 }); 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.***`); 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] } }); await account.updateOne({ $pull: { 'additional.langs': args[0].split('-')[1] } });

View File

@ -41,7 +41,6 @@ export default class Whois extends Command {
embed.setThumbnail(member.avatarURL); embed.setThumbnail(member.avatarURL);
const ackResolve = this.resolveStaffInformation(member.id); const ackResolve = this.resolveStaffInformation(member.id);
let description = ''; let description = '';
if (ackResolve) {
if (ackResolve?.title) { if (ackResolve?.title) {
description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__\n\n`; description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__\n\n`;
} }
@ -57,7 +56,6 @@ export default class Whois extends Command {
if (ackResolve?.bio) { if (ackResolve?.bio) {
description += `${emotes.bio} *${ackResolve.bio}*\n`; description += `${emotes.bio} *${ackResolve.bio}*\n`;
} }
}
description += `\n<@${member.id}>`; description += `\n<@${member.id}>`;
embed.setDescription(description); embed.setDescription(description);