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
+7
-8
@@ -23,7 +23,7 @@ export async function run(msg) {
|
||||
?? msg.message?.serverId;
|
||||
|
||||
const userChannelId = this.players.checkVoiceChannels(msg);
|
||||
if (!userChannelId) return msg.reply(embed("⚠️ Please join a voice channel first."));
|
||||
if (!userChannelId) return msg.reply(embed(this.t(msg, "responses.leave.noVoiceChannel")));
|
||||
|
||||
const cid = String(userChannelId).replace(/\D/g, "");
|
||||
const cleanGuildId = String(guildId ?? "").replace(/\D/g, "");
|
||||
@@ -44,15 +44,14 @@ export async function run(msg) {
|
||||
return liveId ? `<#${liveId}>` : "`unknown voice channel`";
|
||||
});
|
||||
|
||||
if (guildChannels.length === 0) return msg.reply(embed("I'm not in a voice channel."));
|
||||
if (guildChannels.length === 1) return msg.reply(embed(`⚠️ Please join ${guildChannels[0]} to use this command.`));
|
||||
if (guildChannels.length === 0) return msg.reply(embed(this.t(msg, "responses.leave.notInVoice")));
|
||||
if (guildChannels.length === 1) return msg.reply(embed(this.t(msg, "responses.leave.joinChannel", { channel: guildChannels[0] })));
|
||||
return msg.reply(embed(
|
||||
`⚠️ I'm playing in multiple channels! Please join one of them:\n` +
|
||||
guildChannels.map(c => `• ${c}`).join("\n")
|
||||
this.t(msg, "responses.leave.multipleChannels", { channels: guildChannels.map(c => `• ${c}`).join("\n") })
|
||||
));
|
||||
}
|
||||
|
||||
if (!player?.connection) return msg.reply(embed("Player not initialized."));
|
||||
if (!player?.connection) return msg.reply(embed(this.t(msg, "responses.leave.playerNotInit")));
|
||||
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||
const homeChannelId = String(player._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
||||
|
||||
@@ -74,7 +73,7 @@ export async function run(msg) {
|
||||
player.destroy();
|
||||
|
||||
if (mode === "auto") {
|
||||
msg.reply(embed(`✅ Successfully Left — rejoining <#${cid}> in 5 seconds.\nTo disable 24/7 mode permanently, use \`%247 off\`.`));
|
||||
msg.reply(embed(this.t(msg, "responses.leave.leftRejoin247", { channel: cid })));
|
||||
const leave247Delay = this.config?.timers?.leave247RejoinDelay ?? 5000;
|
||||
setTimeout(() => {
|
||||
if (this._spawnPlayer) {
|
||||
@@ -84,7 +83,7 @@ export async function run(msg) {
|
||||
}
|
||||
}, leave247Delay);
|
||||
} else {
|
||||
msg.reply(embed(`✅ Successfully Left.\nℹ️ 24/7 mode is **on** — bot won't rejoin automatically. Use \`%play\` to bring it back, or \`%247 off\` to fully disable.`));
|
||||
msg.reply(embed(this.t(msg, "responses.leave.left247On")));
|
||||
}
|
||||
} else {
|
||||
await this.leaveChannel(activeChannelId, guildId, msg);
|
||||
|
||||
Reference in new issue
Block a user