mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: cleaned node
This commit is contained in:
1 parent
01ed20941d
commit
ab5061ba99
28 files changed
+35
-37
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { serverAndIdPattern } from '../discord/resolvePlayerFromCommand.js';
|
||||
import errorWithCause from '../node/errorWithCause.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
import listClans from './listClans.js';
|
||||
|
||||
export default async function getBlitzClan(clan: string) {
|
||||
@@ -13,7 +13,7 @@ export default async function getBlitzClan(clan: string) {
|
||||
if (accounts[0]) {
|
||||
return { server: accounts[0].server, id: accounts[0].clan_id };
|
||||
} else {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'Could not find clan',
|
||||
`I couldn't find clan \`${clan}\`. Try selecting a username from the search result.`,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers.js';
|
||||
import { TanksStats } from '../../types/tanksStats.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/args.js';
|
||||
import errorWithCause from '../node/errorWithCause.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export default async function getTankStats(server: BlitzServer, id: number) {
|
||||
@@ -10,7 +10,7 @@ export default async function getTankStats(server: BlitzServer, id: number) {
|
||||
);
|
||||
|
||||
if (tankStats[id] === null) {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'No tank stats available',
|
||||
`Wargaming says there is no tank stats for this account. This account may not have any battles/tanks or exist in the ${BLITZ_SERVERS[server]} server.`,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import errorWithCause from '../node/errorWithCause.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
|
||||
export type WargamingResponse<Data extends object> =
|
||||
| {
|
||||
@@ -21,7 +21,7 @@ export default async function getWargamingResponse<Data extends object>(
|
||||
if (parsed.status === 'ok') {
|
||||
return parsed.data;
|
||||
} else {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
`Wargaming response error status:"${parsed.status}"`,
|
||||
`Message: "${parsed.error.message}"\nURL: "${url}"`,
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { Clan, ClanList } from '../../types/clanList.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/args.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export type ClanListWithServer = (Clan & {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { Account, AccountList } from '../../types/accountList.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/args.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export type AccountListWithServer = (Account & {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { go } from 'fuzzysort';
|
||||
import errorWithCause from '../node/errorWithCause.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
import { TANKS, tankopedia } from './tankopedia.js';
|
||||
|
||||
export default function resolveTankId(tank: string) {
|
||||
@@ -9,7 +9,7 @@ export default function resolveTankId(tank: string) {
|
||||
const searchResult = go(tank, TANKS, { keys: ['name'], limit: 1 });
|
||||
|
||||
if (searchResult.length === 0) {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'Tank not found',
|
||||
`Could not find tank by the name "${tank}".`,
|
||||
);
|
||||
@@ -20,7 +20,7 @@ export default function resolveTankId(tank: string) {
|
||||
if (tankopedia[number]) {
|
||||
return number;
|
||||
} else {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'Tank not found',
|
||||
`Could not find tank by the ID "${number}".`,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user