diff --git a/package.json b/package.json index 59c5e31fd..e33550113 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.15.10", + "version": "1.15.11", "description": "🎉 Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module", diff --git a/src/commands/ratings.tsx b/src/commands/ratings.tsx index 9e344bdf9..ecbdc1453 100644 --- a/src/commands/ratings.tsx +++ b/src/commands/ratings.tsx @@ -4,6 +4,7 @@ import { SlashCommandSubcommandBuilder, } from 'discord.js'; import { range } from 'lodash'; +import markdownEscape from 'markdown-escape'; import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard'; import * as Leaderboard from '../components/Leaderboard'; import TitleBar from '../components/TitleBar'; @@ -337,8 +338,7 @@ export const ratingsCommand = new Promise( if (playerIndex === -1) { throw new UserError( - `${accountInfo.nickname} didn't play ratings in season ${season}`, - 'This player did not participate in this season or did not get past calibration.', + `# ${markdownEscape(accountInfo.nickname)} didn't play ratings in season ${season}\nThis player did not participate in this season or did not get past calibration.`, ); } diff --git a/src/core/blitz/getTankStats.ts b/src/core/blitz/getTankStats.ts index 763d720cf..c35df14b5 100644 --- a/src/core/blitz/getTankStats.ts +++ b/src/core/blitz/getTankStats.ts @@ -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.", ); } diff --git a/src/core/blitz/resolveTankId.ts b/src/core/blitz/resolveTankId.ts index 813f5e51a..e175b96fc 100644 --- a/src/core/blitz/resolveTankId.ts +++ b/src/core/blitz/resolveTankId.ts @@ -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.`, ); } } diff --git a/src/core/blitzkrieg/userError.ts b/src/core/blitzkrieg/userError.ts index e4eb7cc27..44a647f15 100644 --- a/src/core/blitzkrieg/userError.ts +++ b/src/core/blitzkrieg/userError.ts @@ -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) {} } diff --git a/src/core/discord/resolveClanFromCommand.ts b/src/core/discord/resolveClanFromCommand.ts index f332ca22e..773723449 100644 --- a/src/core/discord/resolveClanFromCommand.ts +++ b/src/core/discord/resolveClanFromCommand.ts @@ -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.`, ); } } diff --git a/src/core/discord/resolvePlayerFromCommand.ts b/src/core/discord/resolvePlayerFromCommand.ts index fa6d156d1..132994f31 100644 --- a/src/core/discord/resolvePlayerFromCommand.ts +++ b/src/core/discord/resolvePlayerFromCommand.ts @@ -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.", ); } } diff --git a/src/events/interactionCreate/handlers/chatInputCommand.ts b/src/events/interactionCreate/handlers/chatInputCommand.ts index 7d2699725..de02a84cf 100644 --- a/src/events/interactionCreate/handlers/chatInputCommand.ts +++ b/src/events/interactionCreate/handlers/chatInputCommand.ts @@ -11,7 +11,6 @@ import { commands } from '..'; import discord from '../../../../discord.json' assert { type: 'json' }; import { UserError } from '../../../core/blitzkrieg/userError'; import buttonLink from '../../../core/discord/buttonLink'; -import embedNegative from '../../../core/discord/embedNegative'; import embedWarning from '../../../core/discord/embedWarning'; import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable'; import { psa } from '../../../core/discord/psa'; @@ -119,25 +118,15 @@ export default async function handleChatInputCommand( if (error instanceof UserError) { interaction.editReply({ - embeds: [ - embedNegative( - error.message, - (error.cause as string | undefined) ?? - 'No further information is available.', - ), - ], + content: error.message, components, }); } else { console.error(interaction.commandName, error); interaction.editReply({ - embeds: [ - embedNegative( - 'Blitzkrieg ran into an error!', - "We're so sorry about this. Feel free to [join the official Discord server](https://discord.gg/nDt7AjGJQH) to get help.", - ), - ], + content: + "# Blitzkrieg ran into an error!\nWe're so sorry about this. Feel free to [join the official Discord server](https://discord.gg/nDt7AjGJQH) to get help.", components, }); }