mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 06:06:11 +01:00
feat: bug fixes and error safety
This commit is contained in:
1 parent
0b6b2ecedc
commit
780d9d5f8e
25 files changed
+136
-182
No files matched your search
@@ -1,9 +1,9 @@
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { INFO_COLOR } from '../constants/colors.js';
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import cmdName from '../core/interaction/cmdName.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addServerChoices from '../core/options/addServerChoices.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import { args } from '../core/process/args.js';
|
||||
@@ -12,7 +12,7 @@ import { AccountList } from '../types/accountList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -34,27 +34,26 @@ export default {
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const name = interaction.options.getString('username')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const players = await getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}&limit=${limit}`,
|
||||
);
|
||||
if (!players) return;
|
||||
const normalizedSearch = encodeURIComponent(name.trim());
|
||||
const players =
|
||||
normalizedSearch.length >= 3 && normalizedSearch.length <= 100
|
||||
? await getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${normalizedSearch}&limit=${limit}`,
|
||||
)
|
||||
: [];
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setColor(INFO_COLOR)
|
||||
.setTitle(
|
||||
`Player search for "${markdownEscape(name)}" in ${
|
||||
BLITZ_SERVERS[server]
|
||||
}`,
|
||||
)
|
||||
.setDescription(
|
||||
`\`\`\`${
|
||||
players.length === 0
|
||||
? 'No players found.'
|
||||
: players.map((player) => player.nickname).join('\n')
|
||||
}\`\`\``,
|
||||
),
|
||||
infoEmbed(
|
||||
`Player search for "${markdownEscape(name)}" in ${
|
||||
BLITZ_SERVERS[server]
|
||||
}`,
|
||||
`\`\`\`${
|
||||
players.length === 0
|
||||
? 'No players found.'
|
||||
: players.map((player) => player.nickname).join('\n')
|
||||
}\`\`\``,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user