diff --git a/src/commands/score.ts b/src/commands/score.ts index f1d6baf..92b34f0 100644 --- a/src/commands/score.ts +++ b/src/commands/score.ts @@ -16,23 +16,24 @@ export default class Score extends Command { public async run(message: Message, args: string[]) { try { let member: Member; + if (args[0] === 'notify') { + member = message.member; + 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.notify) await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } }); + switch (args[1]) { + case 'on': + await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: true } }); + return this.success(message.channel, 'You will now be sent notifications whenever your score is hard-pulled.'); + case 'off': + await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } }); + return this.success(message.channel, 'You will no longer be sent notifications when your score is hard-pulled.'); + default: + return this.error(message.channel, 'Invalid option. Valid options are `yes` and `no`.'); + } + } if (!args[0] || !this.checkCustomPermissions(message.member, 2)) { member = message.member; - if (args[0] === 'notify') { - 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.notify) await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } }); - switch (args[1]) { - case 'on': - await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: true } }); - return this.success(message.channel, 'You will now be sent notifications whenever your score is hard-pulled.'); - case 'off': - await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } }); - return this.success(message.channel, 'You will no longer be sent notifications when your score is hard-pulled.'); - default: - return this.error(message.channel, 'Invalid option. Valid options are `yes` and `no`.'); - } - } } else { member = this.client.util.resolveMember(args[0], this.mainGuild); if (args[1] === 'hard') {