feat: search min and max lengths

This commit is contained in:
tresabhi committed 2024-12-14 13:27:45 -06:00
1 parent 3b429a6c05
commit 73cb3873d9
6 files changed
+64 -7

No files matched your search

@@ -0,0 +1,23 @@
import { searchClansAcrossRegions } from '@blitzkit/core';
import { Locale } from 'discord.js';
import { UserError } from '../blitzkit/userError';
import { translator } from '../localization/translator';
export async function searchClansAcrossRegionsBotWrapper(
search: string,
locale: Locale,
limit?: number,
) {
const { t } = translator(locale);
const trimmed = search.trim();
if (trimmed.length < 3) {
throw new UserError(t`bot.common.errors.query_too_small`);
}
if (trimmed.length > 100) {
throw new UserError(t`bot.common.errors.query_too_long`);
}
return await searchClansAcrossRegions(trimmed, limit);
}