aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-03-14 00:59:25 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-03-14 00:59:25 -0400
commitbf60ddfed9a4042d37172eca2abb715dba6be4c4 (patch)
treebf6bdb7886fb98f2d90ea6639206f801d204aa38 /src
parentcfcf16ae61dbb313a9b32afd4711a1f1e6a2b4fb (diff)
downloadtanzanite-bf60ddfed9a4042d37172eca2abb715dba6be4c4.tar.gz
tanzanite-bf60ddfed9a4042d37172eca2abb715dba6be4c4.tar.bz2
tanzanite-bf60ddfed9a4042d37172eca2abb715dba6be4c4.zip
fix(price): properly show error messages
Diffstat (limited to 'src')
-rw-r--r--src/commands/utilities/price.ts30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts
index 2af6a76..f6d1104 100644
--- a/src/commands/utilities/price.ts
+++ b/src/commands/utilities/price.ts
@@ -55,15 +55,15 @@ export default class PriceCommand extends BushCommand {
got.get('https://moulberry.codes/lowestbin.json').json().catch(() => { errors.push('current lowest BIN') }),
got.get('https://moulberry.codes/auction_averages_lbin/3day.json').json().catch(() => { errors.push('average Lowest BIN') }),
got.get('https://moulberry.codes/auction_averages/3day.json').json().catch(() => { errors.push('auction average') })
- ])) as [Bazaar, LowestBIN, LowestBIN, AuctionAverages];
+ ])) as [Bazaar | undefined, LowestBIN | undefined, LowestBIN | undefined, AuctionAverages | undefined];
let parsedItem = item.toString().toUpperCase().replace(/ /g, '_').replace(/'S/g, '');
- const priceEmbed = new Embed();
+ const priceEmbed = new Embed().setColor(errors?.length ? util.colors.warn : util.colors.success).setTimestamp();
if (bazaar?.success === false) errors.push('bazaar');
- if (errors?.length) {
- priceEmbed.setFooter({ text: `Could not fetch data from ${util.oxford(errors, 'and', '')}` });
+ if (errors.length) {
+ priceEmbed.setFooter({ text: `Could not fetch data for ${util.oxford(errors, 'and')}` });
}
// create a set from all the item names so that there are no duplicates for the fuzzy search
@@ -85,27 +85,27 @@ export default class PriceCommand extends BushCommand {
}
// if its a bazaar item then it there should not be any ah data
- if (bazaar.products?.[parsedItem]) {
- const bazaarPriceEmbed = new Embed()
- .setColor(errors?.length ? util.colors.warn : util.colors.success)
+ if (bazaar?.products?.[parsedItem]) {
+ priceEmbed
.setTitle(`Bazaar Information for ${util.format.input(parsedItem)}`)
.addFields({ name: 'Sell Price', value: addBazaarInformation('sellPrice', 2, true) })
.addFields({ name: 'Buy Price', value: addBazaarInformation('buyPrice', 2, true) })
.addFields({
name: 'Margin',
- value: (+addBazaarInformation('buyPrice', 2, false) - +addBazaarInformation('sellPrice', 2, false)).toLocaleString()
+ value: (
+ Number(addBazaarInformation('buyPrice', 2, false)) - Number(addBazaarInformation('sellPrice', 2, false))
+ ).toLocaleString()
})
.addFields({ name: 'Current Sell Orders', value: addBazaarInformation('sellOrders', 0, true) })
.addFields({ name: 'Current Buy Orders', value: addBazaarInformation('buyOrders', 0, true) });
- return await message.util.reply({ embeds: [bazaarPriceEmbed] });
+ return await message.util.reply({ embeds: [priceEmbed] });
}
// checks if the item exists in any of the action information otherwise it is not a valid item
if (currentLowestBIN?.[parsedItem] || averageLowestBIN?.[parsedItem] || auctionAverages?.[parsedItem]) {
- priceEmbed
- .setColor(util.colors.success)
- .setTitle(`Price Information for ${util.format.input(parsedItem)}`)
- .setFooter({ text: 'All information is based on the last 3 days.' });
+ priceEmbed.setTitle(`Price Information for ${util.format.input(parsedItem)}`).setFooter({
+ text: `${priceEmbed.footer?.text ? `${priceEmbed.footer.text} | ` : ''}All information is based on the last 3 days.`
+ });
} else {
const errorEmbed = new Embed();
errorEmbed
@@ -133,8 +133,8 @@ export default class PriceCommand extends BushCommand {
): string {
const price = bazaar?.products?.[parsedItem]?.quick_status?.[Information];
return commas
- ? (+price)?.toLocaleString(undefined, { minimumFractionDigits: digits, maximumFractionDigits: digits })
- : (+price)?.toFixed(digits);
+ ? Number(price)?.toLocaleString(undefined, { minimumFractionDigits: digits, maximumFractionDigits: digits })
+ : Number(price)?.toFixed(digits);
}
function addPrice(name: string, price: number | undefined) {
if (price)