mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: no embed errors
This commit is contained in:
1 parent
6094875ffb
commit
8946f115c0
8 files changed
+15
-33
No files matched your search
@@ -11,8 +11,7 @@ export default async function getTankStats(region: Region, id: number) {
|
||||
|
||||
if (tankStats[id] === null) {
|
||||
throw new UserError(
|
||||
'No tank stats available',
|
||||
"This player doesn't have any stats available. This may not be the player you are looking for.",
|
||||
"# No tank stats available\nThis player doesn't have any stats available. This may not be the player you are looking for.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import {
|
||||
tankDefinitions,
|
||||
tanksDefinitionsArray,
|
||||
@@ -16,8 +17,7 @@ export default async function resolveTankId(tank: string | number) {
|
||||
|
||||
if (searchResult.length === 0) {
|
||||
throw new UserError(
|
||||
'Tank not found',
|
||||
`Could not find tank by the name "${tank}".`,
|
||||
`# Tank not found\nCould not find tank by the name "${markdownEscape(tank)}".`,
|
||||
);
|
||||
} else {
|
||||
return searchResult[0].obj.id;
|
||||
@@ -27,8 +27,7 @@ export default async function resolveTankId(tank: string | number) {
|
||||
return number;
|
||||
} else {
|
||||
throw new UserError(
|
||||
'Tank not found',
|
||||
`Could not find tank by the ID "${number}". Try typing the name of the tank instead of a number.`,
|
||||
`# Tank not found\nCould not find tank by the ID "${number}". Try typing the name of the tank instead of a number.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,5 @@
|
||||
* Discriminator for user caused errors to not report in logs
|
||||
*/
|
||||
export class UserError {
|
||||
constructor(
|
||||
public message: string,
|
||||
public cause: string,
|
||||
) {}
|
||||
constructor(public message: string) {}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { Region } from '../../constants/regions';
|
||||
import searchClansAcrossRegions from '../blitz/searchClansAcrossRegions';
|
||||
import { UserError } from '../blitzkrieg/userError';
|
||||
@@ -19,8 +20,7 @@ export default async function resolveClanFromCommand(
|
||||
return { region: accounts[0].region, id: accounts[0].clan_id };
|
||||
} else {
|
||||
throw new UserError(
|
||||
'Could not find clan',
|
||||
`\`${clan}\` was not found. Try selecting a clan from the search result.`,
|
||||
`# Could not find clan\nCouldn't find "${markdownEscape(clan)}". Try selecting a clan from the search result.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ export default async function resolvePlayerFromCommand(
|
||||
} satisfies ResolvedPlayer;
|
||||
} else {
|
||||
throw new UserError(
|
||||
'Could not find user',
|
||||
`I couldn't find user "${markdownEscape(
|
||||
`# Could not find user\nI couldn't find user "${markdownEscape(
|
||||
commandUsername,
|
||||
)}". Try picking an user from the search result, typing in a valid username, or using the \`/link\` command.`,
|
||||
);
|
||||
@@ -49,8 +48,7 @@ export default async function resolvePlayerFromCommand(
|
||||
return { region: account.region, id: account.blitz };
|
||||
} else {
|
||||
throw new UserError(
|
||||
"You're account isn't linked with Blitzkrieg yet",
|
||||
'Use the `/link` command to get started.',
|
||||
"# I don't know who you are\nUse the `/link` command to get started.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user