import { Message } from 'eris'; import { Client, Command, RichEmbed } from '../class'; export default class Score extends Command { constructor(client: Client) { super(client); this.name = 'score'; this.description = 'Gets your Community Score.'; this.usage = 'score'; this.permissions = 0; this.guildOnly = true; this.enabled = true; } public async run(message: Message) { try { const score = await this.client.db.Score.findOne({ userID: message.author.id }); let totalScore = '0'; let activityScore = '0'; let moderationScore = '0'; let roleScore = '0'; let cloudServicesScore = '0'; let miscScore = '0'; if (score) { if (score.total < 200) totalScore = '---'; else if (score.total > 800) totalScore = '800'; else totalScore = `${score.total}`; if (score.activity <= 0) activityScore = '---'; else if (score.activity > 55) activityScore = '55'; else activityScore = `${score.activity}`; if (score.roles <= 0) roleScore = '---'; else if (score.roles > 54) roleScore = '54'; else roleScore = `${score.roles}`; moderationScore = `${score.moderation}`; if (score.staff <= 0) miscScore = '---'; else miscScore = `${score.staff}`; if (score.cloudServices === 0) cloudServicesScore = '---'; else if (score.cloudServices > 50) cloudServicesScore = '50'; else cloudServicesScore = `${score.cloudServices}`; } else return this.error(message.channel, 'Your Community Score has not been calculated yet.'); const embed = new RichEmbed(); embed.setTitle('Community Score'); embed.addField('Total | 200 - 800', totalScore, true); embed.addField('Activity | 10 - 55', activityScore, true); embed.addField('Roles | 1 - 54', roleScore, true); embed.addField('Moderation | -50 - 2', moderationScore, true); embed.addField('Cloud Services | -20 - 50', cloudServicesScore, true); embed.addField('Misc', miscScore, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); return message.channel.createMessage({ embed }); } catch (err) { return this.client.util.handleError(err, message, this); } } }