From df34226a220de7f53f838fe94e36257f7d174bd1 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:11:43 -0600 Subject: [PATCH] feat: more features --- bun.lockb | Bin 389213 -> 389594 bytes packages/bot/package.json | 2 +- packages/bot/src/commands/auction.ts | 48 ++++++++++++++------------- packages/core/lang/en-US.json | 26 ++++++--------- 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/bun.lockb b/bun.lockb index 388393570d525ea4ef8910921e4f24849a0a10dd..400436ef2434116ce6fe99620241d447e3bf9b93 100644 GIT binary patch delta 4072 zcmd6qe^eCL702J~>?&*}NZAIcD5xZ;gk=GNC=tX80b`W#Lqr7utv_N-YiWrREoe+7 zX;jEIc{WDFZx)D20A--WRA@}<4>S}xB_<+*HIk%9?4d^EQTx4c0sW)@^qlncoxS_L z_w(+&nR#>P&CG>vm-D?Y`R3`*&F=G)ptN~C>ptit#M!JV(20oWvU)+?5gW~Q#z|f7b~9h|4tyo1 z{jIvIvpxTA{U~ypX7N6dB>5gcu4C23e1Wh1!1%FN8X1 zOy!Q8<)wt{Vti$`mlCGzk&OuLPx&e$d~m3UCqnF>#~iF3iMkM_k3`{?`=i1KBE?@3 zD@QWZ9*F*gC}pJ2J>dRm3!>#CedivC`~nq`JkpnkC~-JaE@-o+Db5q+7a7XOnlVZ_ z@4gGJ_C@Z;!}}?MF%? z9D@48^Lrc;Z~Iuwox9r>AM74eT+!0L<8t5DvoQtBTk^Ng|H}@~t?^NA106kfiV%vp z>v$KsU;d#`mn5T$bPn=Pq3$W=fQ%^uxJlqp5y0E>76Dr^KuR${k*q8RSXu($Py$dQ zlS=^XN&$`%D3kW3x+JAsrju02MiQHJDuYzY^(0lYnWS2}l|$ZLOhKe6utNX zY!b6Y%*KJ;9g9D-#mpSw>p3r$*+XEjz^C>MGpy<2XUyW5VZF~08yUtk#KS;T@JYASc1H8Mjp0;8$A_T!4KpvWOiDw`0n;tZ#0x+7)nX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LIPV*}b;gX4fXn+_y&2wj`2De6=2PZrZ}#@Y zsO|N7$RO`a|G*#nxla1F`1U5`s3S;_1?mg9Q173Hm4PQ}0?(Iz-kW#arurY!gA=`f zGnP&*Nhs;KcSvuB_m7D6yPUv)T|R4id-CeLi?jBSvHXy}MfzSk)D4bZ&cAwCH?AHw UyGF{f#_o&ePR(fUFk5_o1)4HTUjP6A diff --git a/packages/bot/package.json b/packages/bot/package.json index f66ab8fd3..6e5c7e2fe 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -7,7 +7,7 @@ "@blitzkit/core": "workspace:*", "satori": "^0.10.14", "@resvg/resvg-js": "^2.6.2", - "discord.js": "^14.15.3", + "discord.js": "^14.16.3", "react": "^18.3.1", "@radix-ui/colors": "^3.0.0", "fuzzysort": "^2.0.4", diff --git a/packages/bot/src/commands/auction.ts b/packages/bot/src/commands/auction.ts index eac778a38..fa886a125 100644 --- a/packages/bot/src/commands/auction.ts +++ b/packages/bot/src/commands/auction.ts @@ -29,8 +29,8 @@ type Result = next_price?: Price | null; available: true; display?: boolean; - next_price_datetime?: Date | null; - next_price_timestamp?: number | null; + next_price_datetime: Date; + next_price_timestamp: number; } | { available: false; @@ -69,12 +69,10 @@ interface Currency { export const auctionCommand = new Promise((resolve) => { resolve({ - command: createLocalizedCommand('auction', [ - { subcommand: 'available' }, - { subcommand: 'setup' }, - ]), + command: createLocalizedCommand('auction'), async handler(interaction) { + const { t, translate } = translator(interaction.locale); const awaitedTankDefinitions = await tankDefinitions; const region: Region = 'com'; const pageSize = 80; @@ -86,15 +84,21 @@ export const auctionCommand = new Promise((resolve) => { pageSize }&type[]=vehicle&saleable=${saleable}`, ).then((response) => response.json() as Promise); - const seeableTanks = data.results.filter((result) => result.available); - const { t, translate } = translator(interaction.locale); + const saleableTanks = data.results.filter((result) => result.available); - const title = `# ${t`bot.commands.auction.subcommands.available.body.title`}`; - const subtitle = `-# ${translate( - 'bot.commands.auction.subcommands.available.body.available', - [`${seeableTanks.length} / ${data.results.length}`], - )}`; - const body = seeableTanks + if (saleableTanks.length === 0) { + return t`bot.commands.auction.errors.no_auction`; + } + + const nextPricesTimestamp = saleableTanks[0].next_price_timestamp; + + const title = `# ${t`bot.commands.auction.body.title`}`; + const subtitle = `${translate('bot.commands.auction.body.subtitle', [ + `${saleableTanks.length} / ${data.results.length}`, + ``, + '', + ])}`; + const body = saleableTanks .map((data, index) => { const tank = awaitedTankDefinitions.tanks[data.entity!.id]; @@ -103,14 +107,11 @@ export const auctionCommand = new Promise((resolve) => { const name = `[${tank.name}]()`; - const next = translate( - 'bot.commands.auction.subcommands.available.body.next', - [ - `<:gold:1317173197082333244> ${data.next_price!.value.toLocaleString( - interaction.locale, - )}`, - ], - ); + const next = translate('bot.commands.auction.body.next', [ + `<:gold:1317173197082333244> ${data.next_price!.value.toLocaleString( + interaction.locale, + )}`, + ]); return `${ index + 1 @@ -119,8 +120,9 @@ export const auctionCommand = new Promise((resolve) => { )}\n-# ${next}`; }) .join('\n\n'); + const content = `${title}\n${subtitle}\n\n${body}`; - return `${title}\n${subtitle}\n\n${body}`; + return content; }, }); }); diff --git a/packages/core/lang/en-US.json b/packages/core/lang/en-US.json index d23c62126..3ebb10239 100644 --- a/packages/core/lang/en-US.json +++ b/packages/core/lang/en-US.json @@ -293,22 +293,18 @@ "commands": { "auction": { "$": "auction", - "description": "Tanks available in the auction", + "description": "Tanks available right now in the auction", - "subcommands": { - "available": { - "$": "available", - "description": "Tanks available right now in the auction", - "body": { - "title": "Blitz Auction", - "available": "%s available", - "next": "Next price: %s" - } - }, - "setup": { - "$": "setup", - "description": "Set up a channel to receive auction updates" - } + "body": { + "title": "Blitz Auction", + "subtitle": "%s available • next prices %s\nBid now: %s", + "next": "Next price: %s" + }, + "errors": { + "no_auction": "# No ongoing auction\n\nCurrently, there are no tanks available for purchase in the auction. If you think this is an error, please report this discrepancy in [the official Discord Server](https://discord.gg/nDt7AjGJQH)." + }, + "actions": { + "bid": "Bid now" } },