feat: update bot chunk 3

This commit is contained in:
tresabhi committed 2025-01-16 13:53:29 -06:00
1 parent 122b3f6478
commit 5499cb5cca
9 files changed
+69 -46

No files matched your search

@@ -8,15 +8,15 @@ export async function searchClansAcrossRegionsBotWrapper(
locale: Locale,
limit?: number,
) {
const { t } = translator(locale);
const { strings } = translator(locale);
const trimmed = search.trim();
if (trimmed.length < 3) {
throw new UserError(t`bot.common.errors.query_too_small`);
throw new UserError(strings.bot.common.errors.query_too_small);
}
if (trimmed.length > 100) {
throw new UserError(t`bot.common.errors.query_too_long`);
throw new UserError(strings.bot.common.errors.query_too_long);
}
return await searchClansAcrossRegions(trimmed, limit);
@@ -8,15 +8,15 @@ export async function searchPlayersAcrossRegionsBotWrapper(
locale: Locale,
limit?: number,
) {
const { t } = translator(locale);
const { strings } = translator(locale);
const trimmed = search.trim();
if (trimmed.length < 3) {
throw new UserError(t`bot.common.errors.query_too_small`);
throw new UserError(strings.bot.common.errors.query_too_small);
}
if (trimmed.length > 100) {
throw new UserError(t`bot.common.errors.query_too_long`);
throw new UserError(strings.bot.common.errors.query_too_long);
}
return await searchPlayersAcrossRegions(trimmed, limit);
@@ -38,7 +38,7 @@ export async function getTankHistories(
locale: Locale,
options?: Partial<GetTankHistoriesOptions>,
) {
const { t } = translator(locale);
const { strings } = translator(locale);
const mergedOptions = { ...getTankHistoriesDefaultOptions, ...options };
const tankHistoriesResponse = await fetch(
`https://www.blitzstars.com/api/tankhistories/for/${id}/`,
@@ -82,7 +82,7 @@ export async function getTankHistories(
const tankStats = await getTankStats(server, id);
if (tankStats === null) {
throw new UserError(t`bot.common.errors.no_tank_stats`);
throw new UserError(strings.bot.common.errors.no_tank_stats);
}
tankStats.forEach((tankHistory) => {
@@ -3,16 +3,22 @@ import { translator } from '../localization/translator';
import { localizationObject } from './localizationObject';
export function addUsernameChoices(option: SlashCommandStringOption) {
const { t } = translator(Locale.EnglishUS);
const { strings } = translator(Locale.EnglishUS);
return option
.setName(t`bot.common.options.username`)
.setName(strings.bot.common.options.username.$)
.setNameLocalizations(
localizationObject('bot.common.options.username', undefined, true),
localizationObject(
(strings) => strings.bot.common.options.username.$,
undefined,
true,
),
)
.setDescription(t`bot.common.options.username.description`)
.setDescription(strings.bot.common.options.username.description)
.setDescriptionLocalizations(
localizationObject('bot.common.options.username.description'),
localizationObject(
(strings) => strings.bot.common.options.username.description,
),
)
.setAutocomplete(true);
}
@@ -6,13 +6,13 @@ export function buttonRefresh(
interaction: ChatInputCommandInteraction,
path: string,
) {
const { t } = translator(interaction.locale);
const { strings } = translator(interaction.locale);
if (
interaction.appPermissions?.has('ReadMessageHistory') &&
interaction.appPermissions?.has('ViewChannel')
) {
return buttonPrimary(path, t`bot.common.buttons.refresh`);
return buttonPrimary(path, strings.bot.common.buttons.refresh);
}
return null;