updates to score
parent
6d270ba046
commit
50697482e1
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable default-case */
|
||||
import { Member, Message } from 'eris';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
|
||||
|
@ -6,7 +7,7 @@ export default class Score extends Command {
|
|||
super(client);
|
||||
this.name = 'score';
|
||||
this.description = 'Pulls a hard score report for a member.';
|
||||
this.usage = `${this.client.config.prefix}score <member> <type: 'hard' | 'soft'> <reporting department: ex. Library of Code sp-us | Cloud Account Services>:<reason>`;
|
||||
this.usage = `${this.client.config.prefix}score <member> <type: 'hard' | 'soft'> <reporting department: ex. Library of Code sp-us | Cloud Account Services>:<reason>\n${this.client.config.prefix}score notify <on | off>`;
|
||||
this.permissions = 0;
|
||||
this.guildOnly = true;
|
||||
this.enabled = true;
|
||||
|
@ -17,6 +18,21 @@ export default class Score extends Command {
|
|||
let member: Member;
|
||||
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') {
|
||||
|
@ -26,6 +42,11 @@ export default class Score extends Command {
|
|||
const score = await this.client.db.Score.findOne({ userID: member.user.id });
|
||||
if (!score) return this.error(message.channel, 'Score not calculated yet.');
|
||||
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) => {
|
||||
chan.createMessage(`__**Community Score - Hard Pull Notification**__\n*You have signed up to be notified whenever your hard score has been pulled. See \`?score\` for more information.*\n\n**Department/Service:** ${name.toUpperCase()}`);
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
const score = await this.client.db.Score.findOne({ userID: member.user.id });
|
||||
|
|
|
@ -30,6 +30,7 @@ export interface ScoreInterface extends Document {
|
|||
cloudServices: number,
|
||||
// 0 or 20, 20 points are added if the user is a staff member
|
||||
staff: number,
|
||||
notify: boolean,
|
||||
inquiries: [{ name: string, reason: string, date: Date }],
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,7 @@ const Score: Schema = new Schema({
|
|||
moderation: Number,
|
||||
cloudServices: Number,
|
||||
staff: Number,
|
||||
notify: Boolean,
|
||||
inquiries: Array,
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue