mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: removed search tanks
This commit is contained in:
1 parent
3181f9c4e7
commit
4fedaf1cea
8 files changed
+101
-69
No files matched your search
+26
-14
@@ -1,11 +1,12 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||
import embedInfo from '../core/discord/embedInfo';
|
||||
import markdownTable from '../core/discord/markdownTable';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { translator } from '../core/localization/translator';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
export const playerInfoCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
@@ -13,24 +14,28 @@ export const playerInfoCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('player-info')
|
||||
.setDescription('Basic information about a player')
|
||||
.addStringOption(addUsernameChoices),
|
||||
command:
|
||||
createLocalizedCommand('player-info').addStringOption(addUsernameChoices),
|
||||
|
||||
async handler(interaction) {
|
||||
const { t, translate } = translator(interaction.locale);
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, region: region } = account;
|
||||
const accountInfo = await getAccountInfo(region, id);
|
||||
|
||||
return embedInfo(
|
||||
`${markdownEscape(accountInfo.nickname)}'s information`,
|
||||
translate('bot.command.player_info.body.title', [
|
||||
markdownEscape(accountInfo.nickname),
|
||||
]),
|
||||
|
||||
markdownTable([
|
||||
['Nickname', `${accountInfo.nickname}`],
|
||||
['Battles', `${accountInfo.statistics.all.battles}`],
|
||||
[t`bot.command.player_info.body.nickname`, `${accountInfo.nickname}`],
|
||||
[
|
||||
'Winrate',
|
||||
t`bot.command.player_info.body.battles`,
|
||||
`${accountInfo.statistics.all.battles}`,
|
||||
],
|
||||
[
|
||||
t`bot.command.player_info.body.winrate`,
|
||||
`${(
|
||||
100 *
|
||||
(accountInfo.statistics.all.wins /
|
||||
@@ -38,14 +43,21 @@ export const playerInfoCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
).toFixed(2)}%`,
|
||||
],
|
||||
[],
|
||||
['Account ID', `${accountInfo.account_id}`],
|
||||
[
|
||||
'Created',
|
||||
`${new Date(accountInfo.created_at * 1000).toDateString()}`,
|
||||
t`bot.command.player_info.body.account_id`,
|
||||
`${accountInfo.account_id}`,
|
||||
],
|
||||
[
|
||||
'Last battle',
|
||||
`${new Date(accountInfo.last_battle_time * 1000).toDateString()}`,
|
||||
t`bot.command.player_info.body.created`,
|
||||
new Date(accountInfo.created_at * 1000).toLocaleDateString(
|
||||
interaction.locale,
|
||||
),
|
||||
],
|
||||
[
|
||||
t`bot.command.player_info.body.last_battle`,
|
||||
new Date(accountInfo.last_battle_time * 1000).toLocaleDateString(
|
||||
interaction.locale,
|
||||
),
|
||||
],
|
||||
]),
|
||||
);
|
||||
|
||||
@@ -351,7 +351,9 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
||||
playersAfter =
|
||||
regionRatingsInfo.count - result[result.length - 1].position;
|
||||
titleName = `${
|
||||
leagueInfo ? leagueInfo.title : ''
|
||||
leagueInfo
|
||||
? translate(`common.leagues.${LEAGUES[leagueInfo.index].name}`)
|
||||
: ''
|
||||
} - ${translate(`common.regions.short.${region}`)}`;
|
||||
titleImage = leagueInfo.big_icon.startsWith('http')
|
||||
? leagueInfo.big_icon
|
||||
|
||||
+47
-40
@@ -1,44 +1,51 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { tankNames } from '../core/blitzkrieg/tankDefinitions';
|
||||
import addTankChoices from '../core/discord/addTankChoices';
|
||||
import embedInfo from '../core/discord/embedInfo';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
// _____ _____ _ _ _ _ _____ ____ __ __ ______ ____ _____ _ __
|
||||
// |_ _| / ____| | | | /\ | | | | / ____/ __ \| \/ | ____| | _ \ /\ / ____| |/ /
|
||||
// | | | (___ | |__| | / \ | | | | | | | | | | \ / | |__ | |_) | / \ | | | ' /
|
||||
// | | \___ \| __ | / /\ \ | | | | | | | | | | |\/| | __| | _ < / /\ \| | | <
|
||||
// _| |_ ____) | | | |/ ____ \| |____| |____ | |___| |__| | | | | |____ | |_) / ____ \ |____| . \
|
||||
// |_____| |_____/|_| |_/_/ \_\______|______| \_____\____/|_| |_|______| |____/_/ \_\_____|_|\_\
|
||||
|
||||
export const searchTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
// import { SlashCommandBuilder } from 'discord.js';
|
||||
// import { go } from 'fuzzysort';
|
||||
// import markdownEscape from 'markdown-escape';
|
||||
// import { tankNames } from '../core/blitzkrieg/tankDefinitions';
|
||||
// import addTankChoices from '../core/discord/addTankChoices';
|
||||
// import embedInfo from '../core/discord/embedInfo';
|
||||
// import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('search-tanks')
|
||||
.setDescription('Search tanks')
|
||||
.addStringOption((option) =>
|
||||
addTankChoices(option).setAutocomplete(false),
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName('limit')
|
||||
.setDescription('The size of the search result (default: 25)')
|
||||
.setMinValue(1)
|
||||
.setMaxValue(100),
|
||||
),
|
||||
// export const searchTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
// resolve({
|
||||
// inProduction: true,
|
||||
// inPublic: true,
|
||||
|
||||
async handler(interaction) {
|
||||
const tank = interaction.options.getString('tank')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const results = go(tank, await tankNames, {
|
||||
limit,
|
||||
keys: ['combined'],
|
||||
}).map((result) => result.obj.original);
|
||||
// command: new SlashCommandBuilder()
|
||||
// .setName('search-tanks')
|
||||
// .setDescription('Search tanks')
|
||||
// .addStringOption((option) =>
|
||||
// addTankChoices(option).setAutocomplete(false),
|
||||
// )
|
||||
// .addIntegerOption((option) =>
|
||||
// option
|
||||
// .setName('limit')
|
||||
// .setDescription('The size of the search result (default: 25)')
|
||||
// .setMinValue(1)
|
||||
// .setMaxValue(100),
|
||||
// ),
|
||||
|
||||
return embedInfo(
|
||||
`Tank search for "${markdownEscape(tank)}"`,
|
||||
results.length === 0
|
||||
? 'No tanks found.'
|
||||
: `\`\`\`\n${results.join('\n')}\n\`\`\``,
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
||||
// async handler(interaction) {
|
||||
// const tank = interaction.options.getString('tank')!;
|
||||
// const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
// const results = go(tank, await tankNames, {
|
||||
// limit,
|
||||
// keys: ['combined'],
|
||||
// }).map((result) => result.obj.original);
|
||||
|
||||
// return embedInfo(
|
||||
// `Tank search for "${markdownEscape(tank)}"`,
|
||||
// results.length === 0
|
||||
// ? 'No tanks found.'
|
||||
// : `\`\`\`\n${results.join('\n')}\n\`\`\``,
|
||||
// );
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
Reference in new issue
Block a user