mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
fix: add translation of unexpected error
This commit is contained in:
1 parent
e21679152b
commit
b953179e96
3 files changed
+15
-4
No files matched your search
@@ -11,11 +11,11 @@ import { Logger } from 'pino';
|
||||
import { CustomError, InteractionValidationError } from '../classes/interactions';
|
||||
import loggerModule from '../services/logger';
|
||||
import { BotOptions, EmbedOptions } from '../types/configTypes';
|
||||
import { useServerTranslator } from '../common/localeUtil';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const botOptions: BotOptions = config.get('botOptions');
|
||||
|
||||
// TODO: Update TS Type for handlError
|
||||
export const handleError = async (
|
||||
interaction: Interaction,
|
||||
error: CustomError,
|
||||
@@ -27,6 +27,7 @@ export const handleError = async (
|
||||
name: 'interactionErrorHandler',
|
||||
executionId: executionId
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
if (error instanceof InteractionValidationError || error.type === 'InteractionValidationError') {
|
||||
logger.debug(
|
||||
@@ -35,15 +36,17 @@ export const handleError = async (
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Extract replies for embeds
|
||||
const errorReply: InteractionReplyOptions = {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.error} Uh-oh... _Something_ went wrong!**\nThere was an unexpected error while trying to perform this action. You can try again.\n\n_If this problem persists, please submit a bug report in the **[support server](${botOptions.serverInviteUrl})**._`
|
||||
translator('errors.unexpectedError', {
|
||||
icon: embedOptions.icons.error,
|
||||
serverInviteUrl: botOptions.serverInviteUrl
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.error)
|
||||
.setFooter({ text: `Execution ID: ${executionId}` })
|
||||
.setFooter({ text: translator('errors.footerExecutionId', { executionId: executionId }) })
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user