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])) {
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] } });

View File

@ -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);