mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Final grade calculator
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"above100": [
|
||||||
|
"Maybe there’s extra credit?",
|
||||||
|
"On the bright side, grades don’t really matter anyway.",
|
||||||
|
"Try aiming a little lower.",
|
||||||
|
"Is that even possible to get?",
|
||||||
|
"Better luck next time!"
|
||||||
|
],
|
||||||
|
"above92": [
|
||||||
|
"Don’t give up! You can do it!",
|
||||||
|
"Good luck!",
|
||||||
|
"Don’t give up! I believe in you!",
|
||||||
|
"But I’ve never known you to shy away from a challenge.",
|
||||||
|
"But what’s life without a challenge?",
|
||||||
|
"Start studying!"
|
||||||
|
],
|
||||||
|
"above88": [
|
||||||
|
"On the bright side, it could be a lot worse.",
|
||||||
|
"I think you’ll do just fine!",
|
||||||
|
"Relax, you can do it!",
|
||||||
|
"Good luck!",
|
||||||
|
"Show them what you’ve got!"
|
||||||
|
],
|
||||||
|
"above80": [
|
||||||
|
"Don’t worry, it’ll be a piece of cake.",
|
||||||
|
"You can do it, no problem!",
|
||||||
|
"Good luck!"
|
||||||
|
],
|
||||||
|
"below80": [
|
||||||
|
"You don’t even need to bother studying.",
|
||||||
|
"Have fun (doing other things)!",
|
||||||
|
"Maybe you can just draw a flower on the test or something.",
|
||||||
|
"Congratulations!",
|
||||||
|
"Nice job! You earned it.",
|
||||||
|
"Try aiming higher!"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { above100, above92, above88, above80, below80 } = require('../../assets/json/final-grade-calculator');
|
||||||
|
|
||||||
|
module.exports = class FinalGradeCalculatorCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'final-grade-calculator',
|
||||||
|
aliases: ['final-grade', 'roger-hub'],
|
||||||
|
group: 'number-edit',
|
||||||
|
memberName: 'final-grade-calculator',
|
||||||
|
description: 'Determines the grade you need to make on your final to get your desired course grade.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'current',
|
||||||
|
label: 'current grade',
|
||||||
|
prompt: 'What is your current grade in the class?',
|
||||||
|
type: 'integer',
|
||||||
|
min: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'desired',
|
||||||
|
label: 'desired grade',
|
||||||
|
prompt: 'What is the minimum grade you want in the class?',
|
||||||
|
type: 'integer',
|
||||||
|
min: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'weight',
|
||||||
|
prompt: 'What percentage of your grade is the final worth?',
|
||||||
|
type: 'integer',
|
||||||
|
max: 100,
|
||||||
|
min: 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(msg, { current, desired, weight }) {
|
||||||
|
const weightDecimal = weight / 100;
|
||||||
|
const remainingWeight = 1 - weightDecimal;
|
||||||
|
const required = Math.round(((desired - (current * remainingWeight)) / weightDecimal) * 100);
|
||||||
|
const diff = current - desired;
|
||||||
|
let text;
|
||||||
|
if (required > 100) text = above100[Math.floor(Math.random() * above100.length)];
|
||||||
|
else if (required > 92 || diff > weight * 0.3) text = above92[Math.floor(Math.random() * above92.length)];
|
||||||
|
else if (required > 88 || diff > 0) text = above88[Math.floor(Math.random() * above88.length)];
|
||||||
|
else if (required > 80 || diff > weight * -0.3) text = above80[Math.floor(Math.random() * above80.length)];
|
||||||
|
else text = below80[Math.floor(Math.random() * below80.length)];
|
||||||
|
return msg.say(`You will need to score at least ${required}% on your final to get a ${desired}% overall. ${text}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "58.1.0",
|
"version": "58.2.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user