aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config/config.ts2
-rw-r--r--src/commands/config/log.ts2
-rw-r--r--src/commands/dev/superUser.ts2
-rw-r--r--src/commands/moderation/evidence.ts2
-rw-r--r--src/commands/moderation/role.ts2
-rw-r--r--src/commands/utilities/price.ts35
6 files changed, 20 insertions, 25 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 3f1fc8c..4cab741 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -111,7 +111,7 @@ export default class SettingsCommand extends BushCommand {
}
// I make very readable code :)
- *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
+ override *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
const optional = message.util.parsed!.alias === 'settings';
const setting = yield {
id: 'setting',
diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts
index 49db6f8..03e3582 100644
--- a/src/commands/config/log.ts
+++ b/src/commands/config/log.ts
@@ -34,7 +34,7 @@ export default class LogCommand extends BushCommand {
});
}
- *args(): IterableIterator<ArgumentOptions | Flag> {
+ override *args(): IterableIterator<ArgumentOptions | Flag> {
const log_type = yield {
id: 'log',
type: guildLogsArr,
diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts
index a36972b..4dc4584 100644
--- a/src/commands/dev/superUser.ts
+++ b/src/commands/dev/superUser.ts
@@ -17,7 +17,7 @@ export default class SuperUserCommand extends BushCommand {
});
}
- *args(): IterableIterator<ArgumentOptions | Flag> {
+ override *args(): IterableIterator<ArgumentOptions | Flag> {
const action = yield {
id: 'action',
type: ['add', 'remove'],
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
index 71a52b2..250df24 100644
--- a/src/commands/moderation/evidence.ts
+++ b/src/commands/moderation/evidence.ts
@@ -32,7 +32,7 @@ export default class EvidenceCommand extends BushCommand {
});
}
- *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
+ override *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
const case_id = yield {
id: 'case_id',
type: 'string',
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index d0abb54..69432ab 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -55,7 +55,7 @@ export default class RoleCommand extends BushCommand {
});
}
- *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
+ override *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
const action = ['rr'].includes(message.util.parsed?.alias ?? '')
? 'remove'
: ['ar', 'ra'].includes(message.util.parsed?.alias ?? '')
diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts
index 9ef997a..497935a 100644
--- a/src/commands/utilities/price.ts
+++ b/src/commands/utilities/price.ts
@@ -1,6 +1,6 @@
import { CommandInteraction, MessageEmbed } from 'discord.js';
import Fuse from 'fuse.js';
-import fetch from 'node-fetch';
+import got from 'got';
import { BushCommand, BushMessage } from '../../lib';
interface Summary {
@@ -46,8 +46,6 @@ interface AuctionAverages {
};
}
-type Results = [Promise<Bazaar>, Promise<LowestBIN>, Promise<LowestBIN>, Promise<AuctionAverages>];
-
export default class PriceCommand extends BushCommand {
public constructor() {
super('price', {
@@ -101,16 +99,13 @@ export default class PriceCommand extends BushCommand {
if (message.util.isSlash) await (message.interaction as CommandInteraction).deferReply();
const errors = new Array<string>();
- const promises = (
- await Promise.all([
- fetch('https://api.hypixel.net/skyblock/bazaar').catch(() => errors.push('bazaar')),
- fetch('https://moulberry.codes/lowestbin.json').catch(() => errors.push('current lowest BIN')),
- fetch('https://moulberry.codes/auction_averages_lbin/3day.json').catch(() => errors.push('average Lowest BIN')),
- fetch('https://moulberry.codes/auction_averages/3day.json').catch(() => errors.push('auction average'))
- ])
- ).map(async (request) => await (typeof request === 'number' ? null : request.json())) as unknown as Results;
-
- const [bazaar, currentLowestBIN, averageLowestBIN, auctionAverages] = await Promise.all(promises);
+ //prettier-ignore
+ const [bazaar, currentLowestBIN, averageLowestBIN, auctionAverages] = (await Promise.all([
+ got.get('https://api.hypixel.net/skyblock/bazaar').json().catch(() => errors.push('bazaar')),
+ 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];
let parsedItem = item.toString().toUpperCase().replace(/ /g, '_').replace(/'S/g, '');
const priceEmbed = new MessageEmbed();
@@ -131,13 +126,12 @@ export default class PriceCommand extends BushCommand {
// fuzzy search
if (!strict) {
- const _ = new Fuse(Array.from(itemNames), {
+ parsedItem = new Fuse(Array.from(itemNames), {
isCaseSensitive: false,
findAllMatches: true,
threshold: 0.7,
ignoreLocation: true
- })?.search(parsedItem);
- parsedItem = _[0]?.item;
+ })?.search(parsedItem)[0]?.item;
}
// if its a bazaar item then it there should not be any ah data
@@ -180,18 +174,19 @@ export default class PriceCommand extends BushCommand {
return await message.util.reply({ embeds: [priceEmbed] });
- // helper functions
function addBazaarInformation(
Information: keyof Bazaar['products'][string]['quick_status'],
digits: number,
commas: boolean
): string {
const price = bazaar?.products?.[parsedItem]?.quick_status?.[Information];
- const roundedPrice = Number(Number(price).toFixed(digits));
- return commas ? roundedPrice?.toLocaleString() : roundedPrice?.toString();
+ return commas
+ ? (+price)?.toLocaleString(undefined, { minimumFractionDigits: digits, maximumFractionDigits: digits })
+ : (+price)?.toFixed(digits);
}
function addPrice(name: string, price: number | undefined) {
- if (price) priceEmbed.addField(name, price.toFixed(2).toLocaleString());
+ if (price)
+ priceEmbed.addField(name, price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
}
}
}