diff --git a/src/commands/score.ts b/src/commands/score.ts index 239f0f0..2b630f9 100644 --- a/src/commands/score.ts +++ b/src/commands/score.ts @@ -33,6 +33,20 @@ export default class Score extends Command { return this.error(message.channel, 'Invalid option. Valid options are `yes` and `no`.'); } } + if (args[0] === 'lock' || args[0] === 'unlock') { + if (!member) return this.error(message.channel, 'Member not found.'); + const score = await this.client.db.Score.findOne({ userID: message.author.id }); + if (!score) return this.error(message.channel, 'Score not calculated yet.'); + if (!score.locked) await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } }); + switch (args[0]) { + case 'lock': + await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { locked: true } }); + return this.success(message.channel, 'Your report is now locked.'); + case 'unlock': + await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } }); + return this.success(message.channel, 'Your report is now unlocked.'); + } + } if (!args[0] || !this.checkCustomPermissions(message.member, 2)) { member = message.member; if (!member) return this.error(message.channel, 'Member not found.'); @@ -45,6 +59,7 @@ export default class Score extends Command { const reason = args.slice(2).join(' ').split(':')[1]; const score = await this.client.db.Score.findOne({ userID: member.user.id }); if (!score) return this.error(message.channel, 'Score not calculated yet.'); + if (score.locked) return this.error(message.channel, 'The score report you have requested has been locked.'); await this.client.db.Score.updateOne({ userID: member.user.id }, { $addToSet: { inquiries: { name, reason, date: new Date() } } }); if (score.notify === true) { await this.client.getDMChannel(member.user.id).then((chan) => { @@ -119,6 +134,9 @@ export default class Score extends Command { embed.addField('Cloud Services | N/A to 10+', cloudServicesScore || 'N/C', true); embed.addField('Other', otherScore || 'N/C', true); embed.addField('Misc', miscScore || 'N/C', true); + if (score.locked) { + embed.addField('Status', 'Score Report Locked'); + } if (score.lastUpdate) { embed.setFooter('Report last updated', this.client.user.avatarURL); embed.setTimestamp(score.lastUpdate); diff --git a/src/intervals/score.ts b/src/intervals/score.ts index cfcb6ae..de6246d 100644 --- a/src/intervals/score.ts +++ b/src/intervals/score.ts @@ -38,6 +38,8 @@ export default async function calculateScore(client: Client): Promise