mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +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
@@ -455,5 +455,9 @@
|
|||||||
"queueIsEmpty": "{{icon}} **Oops!\nThere are no tracks added to the queue. First add some tracks with {{playCommand}}!",
|
"queueIsEmpty": "{{icon}} **Oops!\nThere are no tracks added to the queue. First add some tracks with {{playCommand}}!",
|
||||||
"queueNoCurrentTrack": "{{icon}} **Oops!**\nThere is nothing currently playing. First add some tracks with {{playCommand}}!",
|
"queueNoCurrentTrack": "{{icon}} **Oops!**\nThere is nothing currently playing. First add some tracks with {{playCommand}}!",
|
||||||
"trackNotPlayingAnymore": "{{icon}} **Oops!**\nThis track has been skipped or is no longer playing."
|
"trackNotPlayingAnymore": "{{icon}} **Oops!**\nThis track has been skipped or is no longer playing."
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"unexpectedError": "**{{icon}} 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]({{serverInviteUrl}})**._",
|
||||||
|
"footerExecutionId": "Execution ID: {{executionId}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,5 +455,9 @@
|
|||||||
"queueIsEmpty": "{{icon}} **Oi sann!\nDet er ingen låter lagt til i køen. Legg først til noen låter med {{playCommand}}!",
|
"queueIsEmpty": "{{icon}} **Oi sann!\nDet er ingen låter lagt til i køen. Legg først til noen låter med {{playCommand}}!",
|
||||||
"queueNoCurrentTrack": "{{icon}} **Oi sann!**\nDet spilles ingenting av for øyeblikket. Legg først til noen låter med {{playCommand}}!",
|
"queueNoCurrentTrack": "{{icon}} **Oi sann!**\nDet spilles ingenting av for øyeblikket. Legg først til noen låter med {{playCommand}}!",
|
||||||
"trackNotPlayingAnymore": "{{icon}} **Oi sann!**\nDenne låten har blitt hoppet over allerede eller spiller ikke lenger."
|
"trackNotPlayingAnymore": "{{icon}} **Oi sann!**\nDenne låten har blitt hoppet over allerede eller spiller ikke lenger."
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"unexpectedError": "**{{icon}} Å nei... _Noe_ gikk galt!**\nDet oppstod en uventet feil under denne handlingen. Du kan forsøke igjen.\n\n_Hvis dette problemet vedvarer, vennligst send inn en feilrapport i **[støtteserveren]({{serverInviteUrl}})**._",
|
||||||
|
"footerExecutionId": "Referanse ID: {{executionId}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,11 +11,11 @@ import { Logger } from 'pino';
|
|||||||
import { CustomError, InteractionValidationError } from '../classes/interactions';
|
import { CustomError, InteractionValidationError } from '../classes/interactions';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { BotOptions, EmbedOptions } from '../types/configTypes';
|
import { BotOptions, EmbedOptions } from '../types/configTypes';
|
||||||
|
import { useServerTranslator } from '../common/localeUtil';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const botOptions: BotOptions = config.get('botOptions');
|
const botOptions: BotOptions = config.get('botOptions');
|
||||||
|
|
||||||
// TODO: Update TS Type for handlError
|
|
||||||
export const handleError = async (
|
export const handleError = async (
|
||||||
interaction: Interaction,
|
interaction: Interaction,
|
||||||
error: CustomError,
|
error: CustomError,
|
||||||
@@ -27,6 +27,7 @@ export const handleError = async (
|
|||||||
name: 'interactionErrorHandler',
|
name: 'interactionErrorHandler',
|
||||||
executionId: executionId
|
executionId: executionId
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
if (error instanceof InteractionValidationError || error.type === 'InteractionValidationError') {
|
if (error instanceof InteractionValidationError || error.type === 'InteractionValidationError') {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -35,15 +36,17 @@ export const handleError = async (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Extract replies for embeds
|
|
||||||
const errorReply: InteractionReplyOptions = {
|
const errorReply: InteractionReplyOptions = {
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.error)
|
||||||
.setFooter({ text: `Execution ID: ${executionId}` })
|
.setFooter({ text: translator('errors.footerExecutionId', { executionId: executionId }) })
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user