mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: better command error reporting
This commit is contained in:
1 parent
5ef1f87236
commit
92acbc8e95
16 files changed
+668
-31
No files matched your search
@@ -2,9 +2,9 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||
import { client } from '../index.js';
|
||||
import getClientId from '../utilities/getClientId.js';
|
||||
import { tankopedia } from '../utilities/tankopedia.js';
|
||||
import { client } from '../index.js';
|
||||
|
||||
const executionStart = new Date().getTime();
|
||||
|
||||
|
||||
@@ -40,10 +40,12 @@ export default {
|
||||
const name = interaction.options.getString('name')!;
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
|
||||
const command = `eligible ${server} ${name} ${clan}`;
|
||||
|
||||
getBlitzAccount(interaction, name, server, async (account) => {
|
||||
getBlitzAccount(interaction, command, name, server, async (account) => {
|
||||
getBlitzStarsAccount(
|
||||
interaction,
|
||||
command,
|
||||
account.account_id,
|
||||
name,
|
||||
async (data) => {
|
||||
|
||||
@@ -14,7 +14,7 @@ const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -39,8 +39,9 @@ export default {
|
||||
async execute(interaction) {
|
||||
const name = interaction.options.getString('name')!;
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const command = `inactive ${server} ${name}`;
|
||||
|
||||
getClan(interaction, name, server, async (clan) => {
|
||||
getClan(interaction, command, name, server, async (clan) => {
|
||||
const threshold =
|
||||
interaction.options.getNumber('threshold')! ?? DEFAULT_THRESHOLD;
|
||||
const time = new Date().getTime() / 1000;
|
||||
@@ -48,6 +49,7 @@ export default {
|
||||
getWargamingResponse<ClanInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/info/?application_id=${args['wargaming-application-id']}&clan_id=${clan.clan_id}`,
|
||||
interaction,
|
||||
command,
|
||||
async (clanInfo) => {
|
||||
const memberIds = clanInfo[clan.clan_id].members_ids;
|
||||
|
||||
@@ -56,6 +58,7 @@ export default {
|
||||
args['wargaming-application-id']
|
||||
}&account_id=${memberIds.join(',')}`,
|
||||
interaction,
|
||||
command,
|
||||
async (playerPersonalData) => {
|
||||
const inactiveInfo = memberIds
|
||||
.map((memberId) => {
|
||||
|
||||
@@ -30,10 +30,12 @@ export default {
|
||||
const server = interaction.options.getString('server')!;
|
||||
const name = interaction.options.getString('name')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const command = `searchplayers ${server} ${name} ${limit}`;
|
||||
|
||||
getWargamingResponse<Players>(
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}&limit=${limit}`,
|
||||
interaction,
|
||||
command,
|
||||
(players) => {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
|
||||
@@ -39,10 +39,12 @@ export default {
|
||||
| '30'
|
||||
| '90'
|
||||
| 'career';
|
||||
const command = `stats ${server} ${name} ${period}`;
|
||||
|
||||
getBlitzAccount(interaction, name, server, async (account) => {
|
||||
getBlitzAccount(interaction, command, name, server, async (account) => {
|
||||
getBlitzStarsAccount(
|
||||
interaction,
|
||||
command,
|
||||
account.account_id,
|
||||
name,
|
||||
async (data) => {
|
||||
|
||||
@@ -55,11 +55,13 @@ export default {
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const name = interaction.options.getString('name')!;
|
||||
const tier = interaction.options.getInteger('tier')!;
|
||||
const command = `tanks ${server} ${name} ${tier}`;
|
||||
|
||||
getBlitzAccount(interaction, name, server, async (account) => {
|
||||
getBlitzAccount(interaction, command, name, server, async (account) => {
|
||||
getWargamingResponse<TanksStats>(
|
||||
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}`,
|
||||
interaction,
|
||||
command,
|
||||
async (tankStats) => {
|
||||
const tanks = tankStats[account.account_id]!.map(
|
||||
(tankData) => tankopedia.data[tankData.tank_id],
|
||||
|
||||
@@ -25,11 +25,13 @@ export default {
|
||||
execute(interaction) {
|
||||
const name = interaction.options.getString('name')!;
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const command = `verify ${server} ${name}`;
|
||||
|
||||
getBlitzAccount(interaction, name, server, async (account) => {
|
||||
getBlitzAccount(interaction, server, name, server, async (account) => {
|
||||
getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}&extra=clan`,
|
||||
interaction,
|
||||
server,
|
||||
async (clanData) => {
|
||||
const clan = clanData[account.account_id].clan;
|
||||
const clanTag = clan === null ? '' : ` [${clan!.tag}]`;
|
||||
|
||||
Reference in new issue
Block a user