This commit is contained in:
@ -138,20 +138,24 @@ export const get = async (req, res) => {
|
||||
|
||||
const combined = req.query.q;
|
||||
if (!combined || combined.replace(" ", "").length == 0)
|
||||
return res.status(400).json({ error: "Missing query." });
|
||||
return res.status(400).json({ error: "missing-query" });
|
||||
|
||||
let entryFound = false;
|
||||
let estimatedPrice = 0;
|
||||
let subtable, closestInTable;
|
||||
let gameValue = 0;
|
||||
let gameValue = -1;
|
||||
let returnKeyWord = "";
|
||||
|
||||
combined.split(" ").forEach((arg) => {
|
||||
if (!isNaN(parseInt(arg)) && !gameValue) {
|
||||
if (!isNaN(parseInt(arg)) && gameValue == -1) {
|
||||
gameValue = parseInt(arg);
|
||||
}
|
||||
});
|
||||
|
||||
if (gameValue == -1) {
|
||||
return res.status(400).json({ error: "gameValue-not-found" });
|
||||
}
|
||||
|
||||
priceTable.forEach((price, idx) => {
|
||||
if (price.regex.test(combined) && !entryFound) {
|
||||
entryFound = true;
|
||||
@ -183,8 +187,5 @@ export const get = async (req, res) => {
|
||||
closestInTable,
|
||||
});
|
||||
}
|
||||
} else
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Query could not be matched with anything." });
|
||||
} else return res.status(400).json({ error: "entry-not-found" });
|
||||
};
|
||||
|
@ -5,6 +5,7 @@ exports.usage =
|
||||
"CLIENT_PREFIX:bonus <number> <number> [inf optional extra numbers]";
|
||||
exports.example = "CLIENT_PREFIX:bonus 100 100";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
let is1nan = false;
|
||||
if (!args[0])
|
||||
|
@ -3,6 +3,7 @@ exports.description = ":cat: Calculates boost for cat.";
|
||||
exports.usage = "CLIENT_PREFIX:cat <boost> <levels>";
|
||||
exports.example = "CLIENT_PREFIX:cat 80 120";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
if (!args[0] || !args[1])
|
||||
return message.channel.send(
|
||||
|
@ -5,6 +5,7 @@ exports.description =
|
||||
exports.usage = "CLIENT_PREFIX:cb <damage> <ups> [projectile speed]";
|
||||
exports.example = "CLIENT_PREFIX:cb 10000 250 10000";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
if (!args[0] || !args[1])
|
||||
return message.channel.send(
|
||||
|
@ -1,8 +1,8 @@
|
||||
const est = require("./estimate");
|
||||
exports.name = "est";
|
||||
exports.description = ":money_with_wings: Alias for estimate.";
|
||||
exports.usage = "alias";
|
||||
exports.example = "alias";
|
||||
exports.hidden = true;
|
||||
exports.run = async (client, message, args) => {
|
||||
require("./estimate").run(client, message, args);
|
||||
};
|
||||
exports.description = est.description;
|
||||
exports.usage = est.usage;
|
||||
exports.example = est.usage;
|
||||
exports.hidden = false;
|
||||
exports.isAlias = true;
|
||||
exports.run = est.run;
|
||||
|
@ -5,8 +5,9 @@ exports.description =
|
||||
exports.usage =
|
||||
"CLIENT_PREFIX:estimate [summary of item you want the price of]";
|
||||
exports.example =
|
||||
"CLIENT_PREFIX:estimate 1600 ab2\nCLIENT_PREFIX:estimate 1100 thp\nCLIENT_PREFIX:estimate 2400 app builder staff\n(you can also include `showtable` anywhere to show raw price data)\n(always put number first, do not put conflicting data to avoid confusion)";
|
||||
"CLIENT_PREFIX:estimate 1600 ab2\nCLIENT_PREFIX:estimate 1100 thp\nCLIENT_PREFIX:estimate 2400 app builder staff\nCLIENT_PREFIX:estimate 2200 app builder piece\nCLIENT_PREFIX:estimate 2200 app armor\n(you can also include `showtable` anywhere to show raw price data)\n(always put number first, do not put conflicting data to avoid confusion)";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = async (client, message, args) => {
|
||||
if (!args[0]) {
|
||||
return fetch(client.sharedEndpoint + "estimate" + "?getPriceTable=true")
|
||||
@ -22,6 +23,11 @@ exports.run = async (client, message, args) => {
|
||||
}
|
||||
const combined = args.join(" ");
|
||||
let showtable = combined.includes("showtable");
|
||||
if (combined.startsWith("help")) {
|
||||
require("./help").run(client, message, ["estimate"]);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(
|
||||
client.sharedEndpoint +
|
||||
"estimate" +
|
||||
@ -31,7 +37,17 @@ exports.run = async (client, message, args) => {
|
||||
.then((d) => d.json())
|
||||
.then((data) => {
|
||||
if (data.error) {
|
||||
return message.channel.send(data.error);
|
||||
if (data.error == "entry-not-found")
|
||||
return message.channel.send(
|
||||
"Your query couldn't be matched with anything, please refine your query or reffer to `CLIENT_PREFIX:help estimate`. You can also use `CLIENT_PREFIX:estimate` to see all available price tables for more information.".replaceAll(
|
||||
"CLIENT_PREFIX:",
|
||||
client.prefix
|
||||
)
|
||||
);
|
||||
if (data.error == "")
|
||||
return message.channel.send(
|
||||
"API query is somehow empty, but did not error for `entry-not-found`, please contact shiro."
|
||||
);
|
||||
} else {
|
||||
if (showtable) {
|
||||
const { returnKeyWord, subtable } = data;
|
||||
|
@ -74,6 +74,7 @@ exports.usage =
|
||||
"CLIENT_PREFIX:ev <hdmg> <ab2> OR CLIENT_PREFIX:ev <total stats>";
|
||||
exports.example = "CLIENT_PREFIX:ev 6000 5000\nCLIENT_PREFIX:ev 10000";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
if (!args[0])
|
||||
return message.channel.send(
|
||||
|
@ -30,6 +30,7 @@ exports.description = ":muscle: Calculate hero boost's damage multiplier.";
|
||||
exports.usage = "CLIENT_PREFIX:hb <points>";
|
||||
exports.example = "CLIENT_PREFIX:hb 5000";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
if (!args[0])
|
||||
return message.channel.send(
|
||||
|
@ -17,7 +17,11 @@ exports.run = (client, message, args) => {
|
||||
client.prefix
|
||||
)
|
||||
);
|
||||
if (cmd.hidden && message.author.id != client.ownerID) return;
|
||||
if (
|
||||
(cmd.hidden && message.author.id != client.ownerID) ||
|
||||
cmd.description == "alias"
|
||||
)
|
||||
return;
|
||||
embed.setTitle(`Help for \`${cmd.name}\` command`);
|
||||
embed.setDescription(cmd.description);
|
||||
embed.addFields(
|
||||
@ -34,7 +38,11 @@ exports.run = (client, message, args) => {
|
||||
[...client.commands.values()]
|
||||
.sort((a, b) => (a.name > b.name ? 1 : -1))
|
||||
.forEach((cmd) => {
|
||||
if (cmd.hidden && message.author.id != client.ownerID) return;
|
||||
if (
|
||||
(cmd.hidden && message.author.id != client.ownerID) ||
|
||||
cmd.isAlias
|
||||
)
|
||||
return;
|
||||
embed.addFields({
|
||||
name: cmd.name,
|
||||
value: cmd.description.replaceAll(
|
||||
|
@ -5,6 +5,7 @@ exports.description =
|
||||
exports.usage = "CLIENT_PREFIX:ms <elemental damage> <ups> [projectile speed]";
|
||||
exports.example = "CLIENT_PREFIX:ms 10000 250 10000";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
if (!args[0] || !args[1])
|
||||
return message.channel.send(
|
||||
|
@ -14,6 +14,7 @@ exports.description = ":ping_pong: View service statistics.";
|
||||
exports.usage = "CLIENT_PREFIX:ping";
|
||||
exports.example = "CLIENT_PREFIX:ping";
|
||||
exports.hidden = true;
|
||||
exports.isAlias = false;
|
||||
exports.run = async (client, message, args) => {
|
||||
message.channel.send("Fetching data...").then((m) => {
|
||||
m.edit(
|
||||
|
@ -3,6 +3,7 @@ exports.description = ":ninja: Refetch user react data.";
|
||||
exports.usage = "CLIENT_PREFIX:refetch";
|
||||
exports.example = "CLIENT_PREFIX:refetch";
|
||||
exports.hidden = true;
|
||||
exports.isAlias = false;
|
||||
exports.run = async (client, message, args) => {
|
||||
if (message.author.id != client.ownerID) return;
|
||||
try {
|
||||
|
@ -6,6 +6,7 @@ exports.usage =
|
||||
"CLIENT_PREFIX:res <res> <res> <res> [res] | <hero stat> <levels> [second hero stat]";
|
||||
exports.example = "CLIENT_PREFIX:res -3 1 -16 14 | 406 440";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = async (client, message, args) => {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i] == "|") continue;
|
||||
|
@ -31,6 +31,7 @@ exports.description = ":fire: Calculate tower boost's damage multiplier.";
|
||||
exports.usage = "CLIENT_PREFIX:tb <points>";
|
||||
exports.example = "CLIENT_PREFIX:tb 5000";
|
||||
exports.hidden = false;
|
||||
exports.isAlias = false;
|
||||
exports.run = (client, message, args) => {
|
||||
if (!args[0])
|
||||
return message.channel.send(
|
||||
|
Reference in New Issue
Block a user