mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
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:
1 parent
1ff1f9d78f
commit
6060e6d318
36 files changed
+2752
-689
No files matched your search
+5
-6
@@ -29,7 +29,7 @@ export const command = function() {
|
||||
|
||||
export async function run(msg, data) {
|
||||
const radios = this.config.radio;
|
||||
if (!radios?.length) return msg.reply(mkEmbed("❌ No radio stations are configured."));
|
||||
if (!radios?.length) return msg.reply(mkEmbed(this.t(msg, "responses.radio.noStations")));
|
||||
|
||||
const input = (data.get("station")?.value ?? "").trim().toLowerCase();
|
||||
|
||||
@@ -47,8 +47,7 @@ export async function run(msg, data) {
|
||||
desc += `${NUMBER_EMOJIS[i]} **${r.detailedName}** (\`${r.name}\`)\n`;
|
||||
desc += ` ${r.description.replaceAll("\n", "\n ")}\n\n`;
|
||||
});
|
||||
desc += `━━━━━━━━━━━━━━━━━━━━━━\n`;
|
||||
desc += `${PREV_EMOJI} Previous ${NEXT_EMOJI} Next ${CANCEL_EMOJI} Cancel`;
|
||||
desc += `⬅️ Previous ➡️ Next ❌ Cancel`;
|
||||
|
||||
return { payload: mkEmbed(desc), pickable };
|
||||
};
|
||||
@@ -78,7 +77,7 @@ export async function run(msg, data) {
|
||||
settled = true;
|
||||
unobserve();
|
||||
clearReactions().catch(() => {});
|
||||
listMsg.edit(mkEmbed("📻 Radio selection timed out.")).catch(() => {});
|
||||
listMsg.edit(mkEmbed(this.t(msg, "responses.radio.timedOut"))).catch(() => {});
|
||||
}, 60_000);
|
||||
|
||||
const normalize = (s) => s.replace(/\uFE0F/g, "");
|
||||
@@ -92,7 +91,7 @@ export async function run(msg, data) {
|
||||
clearTimeout(timeout);
|
||||
unobserve();
|
||||
await clearReactions();
|
||||
listMsg.edit(mkEmbed("❌ Radio selection cancelled.")).catch(() => {});
|
||||
listMsg.edit(mkEmbed(this.t(msg, "responses.radio.cancelled"))).catch(() => {});
|
||||
return;
|
||||
}
|
||||
if (emoji === normalize(NEXT_EMOJI)) page = (page + 1) % totalPages;
|
||||
@@ -121,7 +120,7 @@ export async function run(msg, data) {
|
||||
const radio = radios.find(r => r.name.toLowerCase() === input);
|
||||
if (!radio) {
|
||||
const names = radios.map(r => `\`${r.name}\``).join(", ");
|
||||
return msg.reply(mkEmbed(`❌ Unknown station \`${input}\`. Available: ${names}\n\nUse \`%radio list\` to browse.`));
|
||||
return msg.reply(mkEmbed(this.t(msg, "responses.radio.unknownStation", { station: input, stations: names })));
|
||||
}
|
||||
return playStation(this, msg, radio);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user