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
+6
-6
@@ -74,7 +74,7 @@ export async function run(msg, data) {
|
||||
|
||||
const nativeMsg = msg.message ?? msg;
|
||||
const rawMsg = await nativeMsg.reply(
|
||||
{ embeds: [makeEmbed("⏳ Loading results...", null, `Searching ${name}...`)] },
|
||||
{ embeds: [makeEmbed(this.t(msg, "responses.search.loadingResults"), this.t(msg, "responses.play.searchingProvider", { provider: name }), `Searching ${name}...`)] },
|
||||
{ ping: false }
|
||||
).catch(() => null);
|
||||
if (!rawMsg) return;
|
||||
@@ -82,7 +82,7 @@ export async function run(msg, data) {
|
||||
// Fetch results
|
||||
const res = await p.fetchResults(query, msg.authorId, provider);
|
||||
if (!res?.count) {
|
||||
rawMsg.edit({ embeds: [makeEmbed("❌ No results found.")] }).catch(() => {});
|
||||
rawMsg.edit({ embeds: [makeEmbed(this.t(msg, "responses.search.noResults"))] }).catch(() => {});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ export async function run(msg, data) {
|
||||
await rawMsg.edit({
|
||||
embeds: [makeEmbed(
|
||||
desc,
|
||||
"React with a number to add to queue • ❌ to cancel • 30s timeout",
|
||||
this.t(msg, "responses.search.reactHint"),
|
||||
`${name} — Search Results`
|
||||
)]
|
||||
}).catch(() => {});
|
||||
@@ -137,7 +137,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (e.emoji_id === CANCEL_EMOJI) {
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed("❌ Cancelled.", null, `${name} — Search Results`)]
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.cancelled"), null, `${name} — Search Results`)]
|
||||
}).catch(() => {});
|
||||
return;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ export async function run(msg, data) {
|
||||
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed(
|
||||
`✅ Added [${v.title}](${v.url}) to the queue!`,
|
||||
this.t(msg, "responses.search.added", { title: v.title, url: v.url }),
|
||||
null,
|
||||
`${name} — Search Results`
|
||||
)]
|
||||
@@ -163,7 +163,7 @@ export async function run(msg, data) {
|
||||
unobserve();
|
||||
clearReactions().catch(() => {});
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed("⏰ Search timed out.", "Session closed", `${name} — Search Results`)]
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.timedOut"), this.t(msg, "responses.search.sessionClosed"), `${name} — Search Results`)]
|
||||
}).catch(() => {});
|
||||
}, SESSION_MS); // configurable via config.timers.searchSessionTimeout
|
||||
}
|
||||
Reference in new issue
Block a user