mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 15:52:55 +01:00
feat: cleaned up directories
This commit is contained in:
1 parent
473ebfa46c
commit
613527e78f
41 files changed
+116
-832
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
CacheType,
|
||||
ChatInputCommandInteraction,
|
||||
EmbedBuilder,
|
||||
} from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers.js';
|
||||
import { Players } from '../../types/players.js';
|
||||
import { args } from '../process/args.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export default async function getBlitzAccount(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
name: string,
|
||||
server: BlitzServer,
|
||||
) {
|
||||
const serverName = BLITZ_SERVERS[server];
|
||||
|
||||
const players = await getWargamingResponse<Players>(
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}`,
|
||||
);
|
||||
|
||||
if (
|
||||
players.length > 0 &&
|
||||
players[0].nickname.toLowerCase() === name.toLowerCase()
|
||||
) {
|
||||
return players[0];
|
||||
} else {
|
||||
// no exact match
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setTitle(`Account not found`)
|
||||
.setDescription(
|
||||
`I couldn't find "${markdownEscape(
|
||||
name,
|
||||
)}" in the ${serverName} server. I found ${
|
||||
players ? (players.length < 100 ? players.length : 'over 100') : 0
|
||||
} similarly spelled account${players?.length !== 1 ? 's' : ''}. ${
|
||||
players && players.length > 0
|
||||
? `Did you mean "${markdownEscape(players[0].nickname)}"? `
|
||||
: ''
|
||||
}Use the \`/verify\` command to fix any issues or re-run the command and don't make typos.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
console.log(`Account not found for ${name} in ${serverName} server.`);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user