fix issues with score notification

pull/29/head
Matthew 2020-09-10 02:08:41 -04:00
parent 6d1671daef
commit 2e6f494c79
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 16 additions and 15 deletions

View File

@ -16,23 +16,24 @@ export default class Score extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
let member: Member; 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)) { if (!args[0] || !this.checkCustomPermissions(message.member, 2)) {
member = message.member; 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 { } else {
member = this.client.util.resolveMember(args[0], this.mainGuild); member = this.client.util.resolveMember(args[0], this.mainGuild);
if (args[1] === 'hard') { if (args[1] === 'hard') {