Having dynmaic reqs

This commit is contained in:
2023-03-21 17:22:39 +01:00
parent cb81d31920
commit 1fee56cd1a
3 changed files with 68 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../config/reqs.json')
const { hypixelApiKey } = require('../config.json'); const { hypixelApiKey } = require('../config.json');
const { color } = require('../config/options.json'); const { color } = require('../config/options.json');
const fetch = require('axios'); const fetch = require('axios');
@@ -60,6 +61,30 @@ module.exports = {
var guildName = "None" var guildName = "None"
} }
const hsbwstars = stats.data.stats.BedWars.level
const hsbwfkdr = stats.data.stats.BedWars.final_k_d
const hsbwwins = stats.data.stats.BedWars.wins
const hsswstars = stats.data.stats.SkyWars.level
const hsduelswins = stats.data.stats.Duels.general.wins
if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) {
var bwtitle = "This player does not meet the BedWars requirements."
} else {
var bwtitle = "This player meets the BedWars requirements."
}
if (hsswstars < swstars) {
var swtitle = "This player does not meet the SkyWars requirements."
} else {
var swtitle = "This player meets the SkyWars requirements."
}
if (hsduelswins < duelswins) {
var duelstitle = "This player does not meet the Duels requirements."
} else {
var duelstitle = "This player meets the Duels requirements."
}
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{
title: stats.data.username, title: stats.data.username,
@@ -75,20 +100,20 @@ module.exports = {
}, },
fields: [ fields: [
{ {
name: "**Bedwars**", name: bwtitle,
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + "`\n" + value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + " / " + bwstars.toString() + "`\n" +
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + "`\n" + "**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + " / " + bwfdkr.toString() + "`\n" +
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + "`" "**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + " / " + bwwins.toString() + "`"
}, },
{ {
name: "**Skywars**", name: swtitle,
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + "`\n" + value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + " / " + swstars.toString() + "`\n" +
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + "**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" +
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" "**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`"
}, },
{ {
name: "**Duels**", name: duelstitle,
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" + value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + " / " + duelswins.toString() + "`\n" +
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + "**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" +
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" "**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`"
} }

7
config/reqs.json Normal file
View File

@@ -0,0 +1,7 @@
{
"bwstars": 120,
"bwfdkr": 2,
"bwwins": 1200,
"swstars": 15,
"duelswins": 5000
}

View File

@@ -3,6 +3,7 @@ const { dev } = require('../../config.json');
const fetch = require('axios'); const fetch = require('axios');
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const guildapp = require('../../schemas/guildAppSchema.js'); const guildapp = require('../../schemas/guildAppSchema.js');
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../../config/reqs.json');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
@@ -41,6 +42,30 @@ module.exports = {
var guildName = "None" var guildName = "None"
} }
const hsbwstars = stats.data.stats.BedWars.level
const hsbwfkdr = stats.data.stats.BedWars.final_k_d
const hsbwwins = stats.data.stats.BedWars.wins
const hsswstars = stats.data.stats.SkyWars.level
const hsduelswins = stats.data.stats.Duels.general.wins
if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) {
var bwtitle = "This player does not meet the BedWars requirements."
} else {
var bwtitle = "This player meets the BedWars requirements."
}
if (hsswstars < swstars) {
var swtitle = "This player does not meet the SkyWars requirements."
} else {
var swtitle = "This player meets the SkyWars requirements."
}
if (hsduelswins < duelswins) {
var duelstitle = "This player does not meet the Duels requirements."
} else {
var duelstitle = "This player meets the Duels requirements."
}
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{
title: stats.data.username, title: stats.data.username,
@@ -56,19 +81,19 @@ module.exports = {
}, },
fields: [ fields: [
{ {
name: "**Bedwars**", name: bwtitle,
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + "`\n" + value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + "`\n" +
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + "`\n" + "**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + "`\n" +
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + "`" "**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + "`"
}, },
{ {
name: "**Skywars**", name: swtitle,
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + "`\n" + value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + "`\n" +
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + "**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" +
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" "**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`"
}, },
{ {
name: "**Duels**", name: duelstitle,
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" + value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" +
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + "**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" +
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" "**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`"