feat: add i18n locale system and fix pagination/help bugs

- Add Locale class (src/constants/Locale.mjs) with per-guild translation
  support and settings-manager binding
- Wire locale into CommandHandler, MessageHandler, Player, PlayerManager,
  and index.mjs via setLocale() / t() helpers
- Replace all hardcoded English strings (help pages, errors, now-playing,
  permission messages, session-closed footers) with locale key lookups
- Fix: %help triggering "Unknown command" — replyHandler intercept now
  uses case-insensitive check for "unknown command"
- Fix: TypeError crash in closeSession when embed has no footer — guard
  with `if (!footer) footer = { text: "" }` before appending
- Fix: media player teardown now calls destroy() and nulls the instance
  instead of relying on _stopMediaPlayer(), preventing stale state
- Refactor: reply() and send() auto-wrap plain strings in embeds,
  matching old replyEmbed/sendEmbed behaviour
- Refactor: permission errors and invalid-flag errors use t() lookups
- Add top-level t(message, key, data) helper on the bot instance for
  command files to resolve guild locale without manual guildId plumbing
This commit is contained in:
NoLogicAlan committed 2026-05-06 01:07:03 +03:00
1 parent 1ff1f9d78f
commit 6060e6d318
36 files changed
+2752 -689

No files matched your search

+10 -7
View File
@@ -145,17 +145,20 @@ export async function run(msg, data) {
// Helper to build the specific embed page
const buildPageContent = (pageIdx, expired = false) => {
const icon = isError ? "❌" : "✅";
const title = `${icon} Eval Result`;
const title = isError
? this.t(msg, "responses.eval.resultTitleError")
: this.t(msg, "responses.eval.resultTitleSuccess");
// Embed description includes the metadata and the codeblock
const desc = `**Type:** \`${type}\` • **Time:** \`${elapsed}ms\`\n\`\`\`js\n${chunks[pageIdx]}\n\`\`\``;
const typeLabel = this.t(msg, "responses.eval.typeLabel");
const timeLabel = this.t(msg, "responses.eval.timeLabel");
const desc = `**${typeLabel}** \`${type}\` • **${timeLabel}** \`${elapsed}ms\`\n\`\`\`js\n${chunks[pageIdx]}\n\`\`\``;
// Customize footer based on state
let footerText = `Page ${pageIdx + 1}/${totalPages}`;
if (expired) footerText = "⌛ Controls expired";
else if (totalPages > 1) footerText += " • ⬅️ ➡️ Navigate • ❌ Delete";
else footerText += " • ❌ Delete";
let footerText = this.t(msg, "responses.eval.pageLabel", { page: pageIdx + 1, total: totalPages });
if (expired) footerText = this.t(msg, "responses.eval.controlsExpired");
else if (totalPages > 1) footerText += " " + this.t(msg, "responses.eval.navigateHint");
else footerText += " " + this.t(msg, "responses.eval.deleteHint");
const embed = new EmbedBuilder()
.setColor(isError ? "#ff0000" : getGlobalColor()) // Red if error, default otherwise