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:*",
"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",
+25 -23
View File
@@ -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<CommandRegistry>((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<CommandRegistry>((resolve) => {
pageSize
}&type[]=vehicle&saleable=${saleable}`,
).then((response) => response.json() as Promise<Auction>);
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}`,
`<t:${nextPricesTimestamp}:R>`,
'<https://wotblitz.com/auction/>',
])}`;
const body = saleableTanks
.map((data, index) => {
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/${
tank.id
}>)`;
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<CommandRegistry>((resolve) => {
)}\n-# ${next}`;
})
.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": {
"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"
}
},