feat: more features

This commit is contained in:
tresabhi committed 2024-12-13 16:11:43 -06:00
1 parent 2f7f2362bb
commit df34226a22
4 files changed
+37 -39

No files matched your search

BIN
View File
Binary file not shown.
+1 -1
View File
@@ -7,7 +7,7 @@
"@blitzkit/core": "workspace:*", "@blitzkit/core": "workspace:*",
"satori": "^0.10.14", "satori": "^0.10.14",
"@resvg/resvg-js": "^2.6.2", "@resvg/resvg-js": "^2.6.2",
"discord.js": "^14.15.3", "discord.js": "^14.16.3",
"react": "^18.3.1", "react": "^18.3.1",
"@radix-ui/colors": "^3.0.0", "@radix-ui/colors": "^3.0.0",
"fuzzysort": "^2.0.4", "fuzzysort": "^2.0.4",
+25 -23
View File
@@ -29,8 +29,8 @@ type Result =
next_price?: Price | null; next_price?: Price | null;
available: true; available: true;
display?: boolean; display?: boolean;
next_price_datetime?: Date | null; next_price_datetime: Date;
next_price_timestamp?: number | null; next_price_timestamp: number;
} }
| { | {
available: false; available: false;
@@ -69,12 +69,10 @@ interface Currency {
export const auctionCommand = new Promise<CommandRegistry>((resolve) => { export const auctionCommand = new Promise<CommandRegistry>((resolve) => {
resolve({ resolve({
command: createLocalizedCommand('auction', [ command: createLocalizedCommand('auction'),
{ subcommand: 'available' },
{ subcommand: 'setup' },
]),
async handler(interaction) { async handler(interaction) {
const { t, translate } = translator(interaction.locale);
const awaitedTankDefinitions = await tankDefinitions; const awaitedTankDefinitions = await tankDefinitions;
const region: Region = 'com'; const region: Region = 'com';
const pageSize = 80; const pageSize = 80;
@@ -86,15 +84,21 @@ export const auctionCommand = new Promise<CommandRegistry>((resolve) => {
pageSize pageSize
}&type[]=vehicle&saleable=${saleable}`, }&type[]=vehicle&saleable=${saleable}`,
).then((response) => response.json() as Promise<Auction>); ).then((response) => response.json() as Promise<Auction>);
const seeableTanks = data.results.filter((result) => result.available); const saleableTanks = data.results.filter((result) => result.available);
const { t, translate } = translator(interaction.locale);
const title = `# ${t`bot.commands.auction.subcommands.available.body.title`}`; if (saleableTanks.length === 0) {
const subtitle = `-# ${translate( return t`bot.commands.auction.errors.no_auction`;
'bot.commands.auction.subcommands.available.body.available', }
[`${seeableTanks.length} / ${data.results.length}`],
)}`; const nextPricesTimestamp = saleableTanks[0].next_price_timestamp;
const body = seeableTanks
const title = `# ${t`bot.commands.auction.body.title`}`;
const subtitle = `${translate('bot.commands.auction.body.subtitle', [
`${saleableTanks.length} / ${data.results.length}`,
`<t:${nextPricesTimestamp}:R>`,
'<https://wotblitz.com/auction/>',
])}`;
const body = saleableTanks
.map((data, index) => { .map((data, index) => {
const tank = awaitedTankDefinitions.tanks[data.entity!.id]; const tank = awaitedTankDefinitions.tanks[data.entity!.id];
@@ -103,14 +107,11 @@ export const auctionCommand = new Promise<CommandRegistry>((resolve) => {
const name = `[${tank.name}](<https://blitzkit.app/tools/tankopedia/${ const name = `[${tank.name}](<https://blitzkit.app/tools/tankopedia/${
tank.id tank.id
}>)`; }>)`;
const next = translate( const next = translate('bot.commands.auction.body.next', [
'bot.commands.auction.subcommands.available.body.next', `<:gold:1317173197082333244> ${data.next_price!.value.toLocaleString(
[ interaction.locale,
`<:gold:1317173197082333244> ${data.next_price!.value.toLocaleString( )}`,
interaction.locale, ]);
)}`,
],
);
return `${ return `${
index + 1 index + 1
@@ -119,8 +120,9 @@ export const auctionCommand = new Promise<CommandRegistry>((resolve) => {
)}\n-# ${next}`; )}\n-# ${next}`;
}) })
.join('\n\n'); .join('\n\n');
const content = `${title}\n${subtitle}\n\n${body}`;
return `${title}\n${subtitle}\n\n${body}`; return content;
}, },
}); });
}); });
+11 -15
View File
@@ -293,22 +293,18 @@
"commands": { "commands": {
"auction": { "auction": {
"$": "auction", "$": "auction",
"description": "Tanks available in the auction", "description": "Tanks available right now in the auction",
"subcommands": { "body": {
"available": { "title": "Blitz Auction",
"$": "available", "subtitle": "%s available • next prices %s\nBid now: %s",
"description": "Tanks available right now in the auction", "next": "Next price: %s"
"body": { },
"title": "Blitz Auction", "errors": {
"available": "%s available", "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)."
"next": "Next price: %s" },
} "actions": {
}, "bid": "Bid now"
"setup": {
"$": "setup",
"description": "Set up a channel to receive auction updates"
}
} }
}, },