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

+1 -1
View File
@@ -14,7 +14,7 @@ export async function run(msg) {
p.clear();
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription("🗑️ Queue cleared.")
.setDescription(this.t(msg, "responses.clear.cleared"))
;
msg.reply({ embeds: [embed] });
}
+1 -1
View File
@@ -28,7 +28,7 @@ export function run(msg, data) {
});
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle("🔧 Voice Debug")
.setTitle(this.t(msg, "responses.debug.voiceTitle"))
.setDescription("```json\n" + JSON.stringify(servers, null, 2) + "\n```")
;
msg.reply({ embeds: [embed] });
+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
+29 -30
View File
@@ -198,26 +198,26 @@ export const command = new CommandBuilder()
.addAliases("filters", "fx", "effect");
// ── Build page embed ──────────────────────────────────────────────────────────
function buildPageEmbed(page, activeKeys, current) {
function buildPageEmbed(t, msg, page, activeKeys, current) {
const totalPages = Math.ceil(FILTERS.length / PAGE_SIZE);
const start = page * PAGE_SIZE;
const pageItems = FILTERS.slice(start, start + PAGE_SIZE);
const trackLine = current
? `🎵 **${Utils.truncate(current.title, 45)}**`
: "*Nothing playing*";
: t(msg, "responses.filter.nothingPlayingInline");
// Show active filter indicators
const activeSet = new Set(activeKeys);
const lines = pageItems.map(f => {
const isActive = activeSet.has(f.key);
const active = isActive ? " **← active**" : "";
const active = isActive ? " " + t(msg, "responses.filter.activeLabel") : "";
return `${f.emoji} **${f.label}**${active} — *${f.desc}*`;
});
const navHint = totalPages > 1
? `\n\n${PREV_EMOJI} Prev ${NEXT_EMOJI} Next ${CANCEL_EMOJI} Close`
: `\n\n${CANCEL_EMOJI} Close`;
? `\n\n${PREV_EMOJI} Prev ${NEXT_EMOJI} Next ${CANCEL_EMOJI} ${t(msg, "responses.filter.closeHint")}`
: `\n\n${CANCEL_EMOJI} ${t(msg, "responses.filter.closeHint")}`;
// Build active summary line
let activeSummary = "";
@@ -231,14 +231,14 @@ function buildPageEmbed(page, activeKeys, current) {
return new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: "🎛️ Audio Filter Picker" })
.setAuthor({ name: t(msg, "responses.filter.pickerTitle") })
.setDescription(
`${trackLine}\n${activeSummary}\n` +
lines.join("\n") +
navHint
)
.setFooter({
text: `Page ${page + 1}/${totalPages} • React with a filter emoji to toggle it`
text: t(msg, "responses.filter.footer", { page: page + 1, total: totalPages })
})
;
}
@@ -265,7 +265,7 @@ export async function run(msg) {
const current = player.queue.getCurrent();
const menuMsg = await msg.reply({
embeds: [buildPageEmbed(page, activeKeys, current)]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, current)]
});
if (!menuMsg?.message) return;
@@ -313,13 +313,13 @@ export async function run(msg) {
const closedEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: "🎛️ Audio Filter Picker" })
.setAuthor({ name: this.t(msg, "responses.filter.pickerTitle") })
.setDescription(
activeKeys.length > 0
? `✅ Filters active: **${activeKeys.map(k => FILTERS.find(f => f.key === k)?.label ?? k).join(" + ")}**.\n\n${reason}`
: `🔇 No filter active.\n\n${reason}`
? this.t(msg, "responses.filter.filtersActive", { filters: activeKeys.map(k => FILTERS.find(f => f.key === k)?.label ?? k).join(" + ") }) + `\n\n${reason}`
: `${this.t(msg, "responses.filter.noFilterActive")}\n\n${reason}`
)
.setFooter({ text: "Session ended" })
.setFooter({ text: this.t(msg, "responses._common.sessionEnded") })
;
await menuMsg.edit({ embeds: [closedEmbed] }).catch(() => {});
@@ -327,7 +327,7 @@ export async function run(msg) {
const resetTimer = () => {
clearTimeout(sessionTimer);
sessionTimer = setTimeout(() => close("⌛ Session timed out."), SESSION_MS);
sessionTimer = setTimeout(() => close(this.t(msg, "responses.filter.sessionTimedOut")), SESSION_MS);
};
const allPossibleEmojis = [...new Set([
@@ -345,7 +345,7 @@ export async function run(msg) {
// ── Navigation ──────────────────────────────────────────────────────────
if (emoji === CANCEL_EMOJI) {
return close("👋 Filter picker closed.");
return close(this.t(msg, "responses.filter.pickerClosed"));
}
if (emoji === PREV_EMOJI) {
@@ -356,7 +356,7 @@ export async function run(msg) {
await addReactions(page);
}
await menuMsg.edit({
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, player.queue.getCurrent())]
}).catch(() => {});
return;
}
@@ -369,7 +369,7 @@ export async function run(msg) {
await addReactions(page);
}
await menuMsg.edit({
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, player.queue.getCurrent())]
}).catch(() => {});
return;
}
@@ -382,16 +382,16 @@ export async function run(msg) {
const previousActiveKeys = [...activeKeys];
if (!track && false) { // pending filters are allowed; keep old fallback block unreachable
await menuMsg.edit({
embeds: [buildPageEmbed(page, activeKeys, null)]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, null)]
}).catch(() => {});
const errEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription("❌ Nothing is playing right now.")
.setDescription(this.t(msg, "responses.filter.nothingPlaying"))
;
await menuMsg.edit({ embeds: [errEmbed] }).catch(() => {});
await Utils.sleep(2000);
await menuMsg.edit({
embeds: [buildPageEmbed(page, activeKeys, null)]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, null)]
}).catch(() => {});
return;
}
@@ -426,14 +426,13 @@ export async function run(msg) {
const errEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription(
`❌ Failed to apply **${filter.label}**: \`${reason}\`\n\n` +
`Make sure your NodeLink node has filters enabled.`
this.t(msg, "responses.filter.applyFailed", { filter: filter.label, reason })
)
;
await menuMsg.edit({ embeds: [errEmbed] }).catch(() => {});
await Utils.sleep(3000);
await menuMsg.edit({
embeds: [buildPageEmbed(page, activeKeys, track)]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, track)]
}).catch(() => {});
return;
}
@@ -443,22 +442,22 @@ export async function run(msg) {
const successMsg = pending
? (filter.key === "off"
? "Filter cleared. Original audio will be used on the next playable track."
? this.t(msg, "responses.filter.pendingCleared")
: activeKeys.includes(filter.key)
? `${filter.label} saved. It will apply on the next playable track.`
: `${filter.label} removed. The next playable track will use the updated filters.`)
? this.t(msg, "responses.filter.pendingApplied", { label: filter.label })
: this.t(msg, "responses.filter.pendingRemoved", { label: filter.label }))
: filter.key === "off"
? "🔇 Filters cleared — original audio restored."
? this.t(msg, "responses.filter.cleared")
: activeKeys.includes(filter.key)
? `${filter.emoji} **${filter.label}** applied!`
: `${filter.emoji} **${filter.label}** removed.`;
? this.t(msg, "responses.filter.applied", { emoji: filter.emoji, label: filter.label })
: this.t(msg, "responses.filter.removed", { emoji: filter.emoji, label: filter.label });
const confirmEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription(
`${successMsg}\n\n` +
`*${filter.desc}*\n\n` +
`💡 React again to toggle, or ${CANCEL_EMOJI} to close.`
`💡 ${this.t(msg, "responses.filter.reactToToggle")}`
)
;
@@ -468,7 +467,7 @@ export async function run(msg) {
// Restore picker (session stays open)
if (!settled) {
await menuMsg.edit({
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, player.queue.getCurrent())]
}).catch(() => {});
}
});
+4 -4
View File
@@ -25,12 +25,12 @@ function cleanId(value) {
export async function run(msg, data) {
const cid = cleanId(data.get("channelId").value);
const targetChannel = this.client.channels.get(cid);
if (!targetChannel) return msg.reply(embed("❌ Channel not found."));
if (!targetChannel) return msg.reply(embed(this.t(msg, "responses.forceleave.channelNotFound")));
if (cleanId(msg.message.guildId) !== cleanId(targetChannel.guildId))
return msg.reply(embed("❌ This command has to be run in the same server as the voice channel."));
return msg.reply(embed(this.t(msg, "responses.forceleave.wrongServer")));
const p = this.players.playerMap.get(cid)
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
if (!p) return msg.reply(embed("❌ Player not found."));
if (!p.connection) return msg.reply(embed("❌ Player not initialized."));
if (!p) return msg.reply(embed(this.t(msg, "responses.forceleave.playerNotFound")));
if (!p.connection) return msg.reply(embed(this.t(msg, "responses.forceleave.playerNotInit")));
await this.players.leave(msg, cid);
}
+2 -4
View File
@@ -9,9 +9,7 @@ export const command = new CommandBuilder()
.setCategory("util");
export async function run(message) {
const description =
"Add Remix to your server directly from [FluxerList](<https://fluxerlist.com/bots/remix>).\n\n" +
"Join our community at [fluxer.gg/remix](https://fluxer.gg/remix) for support, updates, and direct feedback.";
const description = this.t(message, "responses.invite.description");
const botUser = message.handler.client.user;
@@ -20,7 +18,7 @@ export async function run(message) {
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({
name: "Invite Remix",
name: this.t(message, "responses.invite.title"),
iconURL: botIcon
})
.setDescription(description)
+10 -10
View File
@@ -21,7 +21,7 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
if (!this.client.channels.has(cid)) {
ecb();
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription("Couldn't find the channel `" + cid + "`\nUse the help command to learn more about this. (`%help join`)");
.setDescription(this.t(message, "responses.join.channelNotFound", { channel: cid }));
return message.reply({ embeds: [embed] });
}
const cleanChannelId = cleanId(cid);
@@ -30,14 +30,14 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
if (existing) {
cb(existing);
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription("Already joined <#" + cid + ">.");
.setDescription(this.t(message, "responses.join.alreadyJoined", { channel: cid }));
return message.reply({ embeds: [embed] });
}
// Guard: moonlink must be ready before we can play anything
if (!this.moonlink) {
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription("⚠️ Audio node is still connecting — please try again in a few seconds.");
.setDescription(this.t(message, "responses.join.audioNodeConnecting"));
ecb();
return message.reply({ embeds: [embed] });
}
@@ -68,8 +68,8 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
} catch (_) { return "%"; }
})();
const desc = is247
? `Left channel <#${activeChannelId}> because of inactivity.`
: `Left channel <#${activeChannelId}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
? this.t(message, "responses.join.autoLeaveInactive", { channel: activeChannelId })
: this.t(message, "responses.join.autoLeaveInactive247", { channel: activeChannelId, prefix });
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription(desc);
message.channel.send({ embeds: [embed] });
@@ -91,17 +91,17 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
this.players.playerMap.set(cleanChannelId, p);
const joiningEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("⏳ Joining Channel...");
const joiningEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.join.joining"));
const statusMsg = await message.reply({ embeds: [joiningEmbed] });
try {
await p.join(cleanChannelId);
const okEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(`✅ Successfully joined <#${cid}>`);
const okEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.join.joined", { channel: cid }));
await statusMsg.edit({ embeds: [okEmbed] });
cb(p);
} catch (e) {
this.players.playerMap.delete(cleanChannelId);
p.destroy();
const errEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(`❌ Failed to join: ${e.message}`);
const errEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.join.joinFailed", { error: e.message }));
await statusMsg.edit({ embeds: [errEmbed] });
ecb(e);
}
@@ -150,7 +150,7 @@ export function run(message, data) {
if (!resolvedId) {
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription("❌ Couldn't find that voice channel. Try using a mention like `<#channelid>` or the exact channel name.");
.setDescription(this.t(message, "responses.join.voiceChannelNotFound"));
return message.reply({ embeds: [embed] });
}
@@ -163,7 +163,7 @@ export function run(message, data) {
if (!cid) {
const prefix = this._commands?.getPrefix?.(getGuildId(message)) ?? "%";
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription(`❌ You're not in a voice channel. Please join one first, or specify a channel: \`${prefix}join <#channel>\``);
.setDescription(this.t(message, "responses.join.noVoiceChannel", { prefix }));
return message.reply({ embeds: [embed] });
}
+7 -8
View File
@@ -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);
+4 -4
View File
@@ -24,7 +24,7 @@ export async function run(message, data) {
const totalTracks = p.queue.size();
if (!current && totalTracks === 0) {
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("📭 The queue is empty. Use `%play` to add songs!");
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.list.empty", { prefix: "%" }));
return message.reply({ embeds: [embed] });
}
@@ -54,7 +54,7 @@ export async function run(message, data) {
if (title.length > 50) title = title.slice(0, 47) + "...";
const titleFmt = link ? `[${title}](${link})` : title;
desc += `\n🎵 **Now Playing**\n`;
desc += "\n" + this.t(message, "responses.list.nowPlaying") + "\n";
desc += `${titleFmt} • \`${elapsed} / ${total}\`\n`;
}
@@ -62,7 +62,7 @@ export async function run(message, data) {
// ── Queue list ────────────────────────────────────────────────────────
if (totalTracks === 0) {
desc += "_Queue is empty._";
desc += this.t(message, "responses.list.emptyInline");
} else {
const { items, start } = p.queue.getPage(safePage, PAGE_SIZE);
@@ -82,7 +82,7 @@ export async function run(message, data) {
return new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: "🎧 Queue" })
.setAuthor({ name: this.t(message, "responses.list.queueTitle") })
.setDescription(desc.trim())
.setFooter({ text: `Page ${safePage}/${totalPages} • ${loopState}` })
;
+3 -3
View File
@@ -15,14 +15,14 @@ export async function run(msg, data) {
const code = data.get("id").value;
if (!this.dashboard?.enabled) {
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ The dashboard is not enabled on this bot.");
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.login.dashboardDisabled"));
return msg.reply({ embeds: [embed] });
}
const error = await this.dashboard.confirmLogin(msg.author.id, code);
const desc = (error === null)
? "✅ Login succeeded! You can continue to the webpage now."
: "❌ Login failed! Reason: `" + error + "`. If this is an error and the issue persists, please contact a team member through the server in my description.";
? this.t(msg, "responses.login.success")
: this.t(msg, "responses.login.failed", { error });
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
msg.reply({ embeds: [embed] });
+10 -11
View File
@@ -20,7 +20,7 @@ export async function run(message) {
const current = p.queue.getCurrent();
if (!current) {
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ There's nothing playing at the moment.");
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.lyrics.nothingPlaying"));
return message.reply({ embeds: [embed] });
}
@@ -28,7 +28,7 @@ export async function run(message) {
let frame = 0;
const loadingMsg = await message.reply({ embeds: [
new EmbedBuilder().setColor(getGlobalColor())
.setDescription(`${LOADING_FRAMES[0]} Searching lyrics for **${Utils.truncate(current.title, 40)}**...`)
.setDescription(`${LOADING_FRAMES[0]} ` + this.t(message, "responses.lyrics.searching", { title: Utils.truncate(current.title, 40) }))
] });
@@ -36,7 +36,7 @@ export async function run(message) {
frame = (frame + 1) % LOADING_FRAMES.length;
loadingMsg.edit({ embeds: [
new EmbedBuilder().setColor(getGlobalColor())
.setDescription(`${LOADING_FRAMES[frame]} Searching lyrics for **${Utils.truncate(current.title, 40)}**...`)
.setDescription(`${LOADING_FRAMES[frame]} ` + this.t(message, "responses.lyrics.searching", { title: Utils.truncate(current.title, 40) }))
] }).catch(() => {});
}, 800);
@@ -50,15 +50,14 @@ export async function run(message) {
return loadingMsg.edit({ embeds: [
new EmbedBuilder().setColor(getGlobalColor())
.setDescription(
`❌ No lyrics available for **${Utils.truncate(current.title, 40)}**.\n\n` +
`💡 NodeLink lyrics plugin may not have this track. Try a popular song!`
this.t(message, "responses.lyrics.noLyrics", { title: Utils.truncate(current.title, 40) })
)
] });
}
try { await loadingMsg.message.delete(); } catch {}
const syncIndicator = result.synced ? " ⏱️ Synced" : "";
const syncIndicator = result.synced ? this.t(message, "responses.lyrics.syncedBadge") : "";
const displayTitle = Utils.cleanTitle(current.title);
const artist = current.artists?.[0]?.name || current.author?.name || "Unknown Artist";
const lines = result.text.split("\n").filter(l => l.trim());
@@ -79,7 +78,7 @@ export async function run(message) {
lines.join("\n"),
"```"
].join("\n"))
.setFooter({ text: `NodeLink • ${totalLines} lines` });
.setFooter({ text: this.t(message, "responses.lyrics.nodeLinkFooter", { lines: totalLines }) });
if (current.thumbnail) singleEmbed.setThumbnail(current.thumbnail);
return message.reply({ embeds: [singleEmbed] });
}
@@ -105,8 +104,8 @@ export async function run(message) {
"```"
].join("\n"))
.setFooter({ text: expired
? `⌛ Controls expired • NodeLink • ${totalLines} lines`
: `NodeLink • ${totalLines} lines total` });
? this.t(message, "responses.lyrics.controlsExpired", { lines: totalLines })
: this.t(message, "responses.lyrics.nodeLinkFooter", { lines: totalLines }) });
if (current.thumbnail) b.setThumbnail(current.thumbnail);
return { embeds: [b] };
};
@@ -163,7 +162,7 @@ export async function run(message) {
pages[currentPage],
"```"
].join("\n"))
.setFooter({ text: `Session closed • NodeLink • ${totalLines} lines` });
.setFooter({ text: this.t(message, "responses.lyrics.sessionClosed", { lines: totalLines }) });
if (current.thumbnail) closedEmbed.setThumbnail(current.thumbnail);
msg.edit({ embeds: [closedEmbed] }).catch(() => {});
}, SESSION_MS);
@@ -171,6 +170,6 @@ export async function run(message) {
} catch (err) {
clearInterval(loadingInterval);
logger.error("[Lyrics Command] Error:", err);
loadingMsg.edit({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`❌ Error: ${Utils.truncate(err.message, 100)}`)] }).catch(() => {});
loadingMsg.edit({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.lyrics.error", { error: Utils.truncate(err.message, 100) }))] }).catch(() => {});
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ export async function run(msg) {
const loadingEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription("⏳ Loading...")
.setDescription(this.t(msg, "responses.np.loading"))
;
const loadingMsg = await msg.reply({ embeds: [loadingEmbed] });
+1 -1
View File
@@ -56,7 +56,7 @@ export async function run(message, data) {
const searchEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription("🔍 Searching...")
.setDescription(this.t(message, "responses.play.searching"))
;
let statusMsg = null;
+34 -34
View File
@@ -110,10 +110,10 @@ export async function run(msg) {
const nowPlaying = current
? `[${Utils.truncate(current.title, 45)}](${current.spotifyUrl || current.url})`
: "*Nothing playing*";
: this.t(msg, "responses.filter.nothingPlayingInline");
const description = [
`${statusEmoji} **Now Playing**`,
`${statusEmoji} ${this.t(msg, "responses.player.nowPlayingLabel")}`,
`${nowPlaying}`,
``,
`${progressBar}`,
@@ -122,9 +122,9 @@ export async function run(msg) {
`🔊 Volume: \`${volPercent}%\` ${volumeBar}`,
`📋 Queue: \`${queueSize}\` tracks | Loop: ${loopStatus} | Filter: ${filterStatus}`,
``,
state.message ? `💬 *${state.message}*` : "💡 *React to control playback*",
state.message ? `💬 *${state.message}*` : `💡 *${this.t(msg, "responses.player.reactHint")}*`,
``,
`⏱️ Session expires in ${Math.ceil(timeout / 60000)}m of inactivity`
this.t(msg, "responses.player.sessionExpires", { minutes: Math.ceil(timeout / 60000) })
].join("\n");
const avatarUrl = typeof msg.author?.avatarURL === "function"
@@ -133,10 +133,10 @@ export async function run(msg) {
const builder = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle("🎧 Music Player Controls")
.setTitle(this.t(msg, "responses.player.title"))
.setDescription(description)
.setFooter({
text: `Requested by ${msg.author?.username || "Unknown"} • Controls active`,
text: this.t(msg, "responses.player.requestedBy", { username: msg.author?.username || "Unknown" }),
iconURL: avatarUrl
});
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
@@ -181,8 +181,8 @@ export async function run(msg) {
clearTimeout(emojiRemoveTimeout);
emojiRemoveTimeout = setTimeout(async () => {
await clearReactions();
const disabledEmbed = buildEmbed({ message: "⌛ Controls disabled (react to re-enable)" });
disabledEmbed.footer = { text: "Controls expired • React to refresh" };
const disabledEmbed = buildEmbed({ message: this.t(msg, "responses.player.controlsDisabled") });
disabledEmbed.footer = { text: this.t(msg, "responses._common.controlsExpired") + " • React to refresh" };
await message.edit({ embeds: [disabledEmbed] }).catch(() => {});
}, EMOJI_REMOVE_TIMEOUT);
};
@@ -236,15 +236,15 @@ export async function run(msg) {
await clearReactions();
const closedEmbed = buildEmbed({
message: `Session closed${reason !== "timeout" ? ` • ${reason}` : " due to inactivity"}`
message: this.t(msg, "responses.player.sessionClosed", { reason: reason !== "timeout" ? ` • ${reason}` : "" })
});
closedEmbed.color = getGlobalColor();
closedEmbed.footer = { text: "Session ended" };
closedEmbed.title = "🎧 Music Player (Inactive)";
closedEmbed.footer = { text: this.t(msg, "responses._common.sessionEnded") };
closedEmbed.title = this.t(msg, "responses.player.inactiveTitle");
await message.edit({
embeds: [closedEmbed],
content: reason === "user" ? "👋 Player controls closed" : undefined
content: reason === "user" ? this.t(msg, "responses.player.closedByUser") : undefined
}).catch(() => {});
};
@@ -259,21 +259,21 @@ export async function run(msg) {
}
}, this.config?.timers?.playerUpdateInterval ?? 5000);
const onStartPlay = () => refresh({ message: "▶️ Started playing" });
const onPlayback = (playing) => refresh({ message: playing ? "▶️ Resumed" : "⏸️ Paused" });
const onStopPlay = () => refresh({ message: "⏹️ Stopped" });
const onStartPlay = () => refresh({ message: this.t(msg, "responses.player.startedPlaying") });
const onPlayback = (playing) => refresh({ message: playing ? this.t(msg, "responses.player.resumed") : this.t(msg, "responses.player.pausedState") });
const onStopPlay = () => refresh({ message: this.t(msg, "responses.player.stopped") });
const onQueue = (e) => {
if (e.type === "shuffle") refresh({ message: "🔀 Queue shuffled" });
if (e.type === "add") refresh({ message: `➕ Added: ${Utils.truncate(e.data.data.title, 30)}` });
if (e.type === "shuffle") refresh({ message: this.t(msg, "responses.player.shuffled") });
if (e.type === "add") refresh({ message: this.t(msg, "responses.player.added", { title: Utils.truncate(e.data.data.title, 30) }) });
};
const onVolume = (v) => refresh({ message: `🔊 Volume: ${Math.round(v * 100)}%` });
const onVolume = (v) => refresh({ message: this.t(msg, "responses.player.volumeChanged", { volume: Math.round(v * 100) }) });
const onFilter = (f) => {
if (!f) {
refresh({ message: "🔇 Filters cleared" });
refresh({ message: this.t(msg, "responses.player.filtersCleared") });
} else if (f.label.includes("+")) {
refresh({ message: `🔥 Filters: **${f.label}** applied` });
refresh({ message: this.t(msg, "responses.player.filterStackedApplied", { label: f.label }) });
} else {
refresh({ message: `${f.emoji ?? "🎛️"} Filter: **${f.label}** applied` });
refresh({ message: this.t(msg, "responses.player.filterApplied", { emoji: f.emoji ?? "🎛️", label: f.label }) });
}
};
const onAutoLeave = () => closeSession("disconnected");
@@ -299,7 +299,7 @@ export async function run(msg) {
try {
switch (control.action) {
case "previous":
reply = "⏮️ Previous track (not implemented)";
reply = this.t(msg, "responses.player.previousNotImplemented");
break;
case "resume":
@@ -307,9 +307,9 @@ export async function run(msg) {
reply = player.resume();
} else if (!player.queue.getCurrent() && !player.queue.isEmpty()) {
player.playNext();
reply = "▶️ Starting playback";
reply = this.t(msg, "responses.player.startingPlayback");
} else {
reply = "▶️ Already playing";
reply = this.t(msg, "responses.player.alreadyPlaying");
}
break;
@@ -320,7 +320,7 @@ export async function run(msg) {
case "stop":
await player._stopMediaPlayer();
player.queue.reset();
reply = "⏹️ Stopped and cleared";
reply = this.t(msg, "responses.player.stoppedCleared");
break;
case "skip":
@@ -332,14 +332,14 @@ export async function run(msg) {
const currentSongLoop = player.queue.songLoop;
if (!currentLoop && !currentSongLoop) {
player.queue.setSongLoop(true);
reply = "🔂 Song loop enabled";
reply = this.t(msg, "responses.player.songLoopEnabled");
} else if (currentSongLoop) {
player.queue.setSongLoop(false);
player.queue.setLoop(true);
reply = "🔁 Queue loop enabled";
reply = this.t(msg, "responses.player.queueLoopEnabled");
} else {
player.queue.setLoop(false);
reply = "❌ Loop disabled";
reply = this.t(msg, "responses.player.loopDisabled");
}
break;
}
@@ -361,18 +361,18 @@ export async function run(msg) {
}
case "filter":
reply = "🎛️ Opening filter picker — check the filter menu above or use the `filter` command.";
reply = this.t(msg, "responses.player.openingFilterPicker");
shouldUpdate = true;
try {
const { run: runFilter } = await import("./filter.mjs");
runFilter.call(this, msg);
} catch (err) {
reply = `⚠️ Filter error: ${Utils.truncate(err.message, 50)}`;
reply = this.t(msg, "responses.player.filterError", { error: Utils.truncate(err.message, 50) });
}
break;
case "lyrics":
reply = "📜 Fetching lyrics...";
reply = this.t(msg, "responses.player.fetchingLyrics");
refresh({ message: reply });
try {
@@ -384,7 +384,7 @@ export async function run(msg) {
const lyricsResult = await player.lyrics();
if (!lyricsResult) {
reply = "❌ No lyrics found in NodeLink";
reply = this.t(msg, "responses.player.noLyricsFound");
shouldUpdate = true;
break;
}
@@ -483,10 +483,10 @@ export async function run(msg) {
resetLyricsTimer();
}
reply = `Lyrics displayed (${totalLines} lines, ${totalPages} pages)`;
reply = this.t(msg, "responses.player.lyricsDisplayed", { lines: totalLines, pages: totalPages });
} catch (err) {
reply = `⚠️ Lyrics error: ${Utils.truncate(err.message, 50)}`;
reply = this.t(msg, "responses.player.lyricsError", { error: Utils.truncate(err.message, 50) });
}
shouldUpdate = true;
break;
+1 -1
View File
@@ -48,7 +48,7 @@ export async function run(message, data) {
const searchEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription("🔍 Searching...")
.setDescription(this.t(message, "responses.playnext.searching"))
;
const statusMsg = await message.reply({ embeds: [searchEmbed] });
+5 -6
View File
@@ -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);
}
+22 -22
View File
@@ -24,15 +24,15 @@ const __dirname = path.dirname(new URL(import.meta.url).pathname);
const ROOT = path.resolve(__dirname, "..");
// ── Reload a single command ───────────────────────────────────────────────────
async function reloadCommand(ctx, name) {
async function reloadCommand(ctx, msg, name) {
if (name === "index")
return { ok: false, msg: "❌ `index.mjs` cannot be hot-reloaded — do a full restart." };
return { ok: false, msg: ctx.t(msg, "responses.reload.indexNoReload") };
const command = ctx.handler.commands.find(c => c.name === name);
if (!command) return { ok: false, msg: `❌ Unknown command \`${name}\`` };
if (!command) return { ok: false, msg: ctx.t(msg, "responses.reload.unknownCommand", { name }) };
const file = ctx.commandFiles.get(command.uid);
if (!file) return { ok: false, msg: `❌ No file tracked for \`${name}\`` };
if (!file) return { ok: false, msg: ctx.t(msg, "responses.reload.noFileTracked", { name }) };
// Unregister old
command.subcommands.forEach(sub => ctx.runnables.delete(sub.uid));
@@ -47,7 +47,7 @@ async function reloadCommand(ctx, name) {
const raw = cData.command ?? cData.default?.command;
const builder = typeof raw === "function" ? raw.call(ctx) : raw;
if (!builder) return { ok: false, msg: `❌ No builder returned from \`${name}\`` };
if (!builder) return { ok: false, msg: ctx.t(msg, "responses.reload.noBuilder", { name }) };
const runFn = cData.run ?? cData.default?.run;
const exportDef = cData.exportDef ?? cData.export ?? cData.default?.exportDef ?? cData.default?.export;
@@ -60,18 +60,18 @@ async function reloadCommand(ctx, name) {
builder.subcommands.forEach(sub => ctx.runnables.set(sub.uid, runFn));
}
return { ok: true, msg: `✅ \`${name}\`` };
return { ok: true, msg: ctx.t(msg, "responses.reload.reloaded", { name }) };
}
// ── Reload a src/ or audio/ module ───────────────────────────────────────────
async function reloadModule(ctx, filePath, label) {
async function reloadModule(ctx, msg, filePath, label) {
if (!fs.existsSync(filePath))
return { ok: false, msg: `❌ File not found: \`${label}\`` };
return { ok: false, msg: ctx.t(msg, "responses.reload.fileNotFound", { label }) };
try {
await import(pathToFileURL(filePath).href + "?t=" + Date.now());
return { ok: true, msg: `✅ \`${label}\`` };
return { ok: true, msg: ctx.t(msg, "responses.reload.reloaded", { name: label }) };
} catch (e) {
return { ok: false, msg: `❌ \`${label}\`: ${e.message}` };
return { ok: false, msg: ctx.t(msg, "responses.reload.moduleError", { label, error: e.message }) };
}
}
@@ -139,51 +139,51 @@ export async function run(msg, data) {
const audLines = allModuleFiles("audio").map(m => `🎵 \`${m.label}\` *(audio)*`);
const lines = [
"Run `%reload <target>` or use a batch keyword:",
"`all` · `commands` · `src` · `audio`",
this.t(msg, "responses.reload.runHint"),
this.t(msg, "responses.reload.batchKeywords"),
"",
...cmdLines,
...srcLines,
...audLines,
];
return showPaged(msg, "🔄 Reload — Available Targets", lines);
return showPaged(msg, this.t(msg, "responses.reload.availableTargetsTitle"), lines);
}
// Batch keywords
if (target === "commands") {
const results = await Promise.all(
this.handler.commands.map(c => reloadCommand(this, c.name))
this.handler.commands.map(c => reloadCommand(this, msg, c.name))
);
return showResults(msg, results, "Commands");
}
if (target === "src") {
const results = await Promise.all(
allModuleFiles("src").map(m => reloadModule(this, m.file, m.label))
allModuleFiles("src").map(m => reloadModule(this, msg, m.file, m.label))
);
return showResults(msg, results, "src/");
}
if (target === "audio") {
const results = await Promise.all(
allModuleFiles("audio").map(m => reloadModule(this, m.file, m.label))
allModuleFiles("audio").map(m => reloadModule(this, msg, m.file, m.label))
);
return showResults(msg, results, "audio/");
}
if (target === "all") {
const results = await Promise.all([
...this.handler.commands.map(c => reloadCommand(this, c.name)),
...allModuleFiles("src").map(m => reloadModule(this, m.file, m.label)),
...allModuleFiles("audio").map(m => reloadModule(this, m.file, m.label)),
...this.handler.commands.map(c => reloadCommand(this, msg, c.name)),
...allModuleFiles("src").map(m => reloadModule(this, msg, m.file, m.label)),
...allModuleFiles("audio").map(m => reloadModule(this, msg, m.file, m.label)),
]);
return showResults(msg, results, "Everything");
}
// Single command by name
if (this.handler.commands.some(c => c.name === target)) {
const res = await reloadCommand(this, target);
const res = await reloadCommand(this, msg, target);
return msg.reply(embed(res.msg));
}
@@ -195,11 +195,11 @@ export async function run(msg, data) {
);
if (mod) {
const res = await reloadModule(this, mod.file, mod.label);
const res = await reloadModule(this, msg, mod.file, mod.label);
return msg.reply(embed(res.msg));
}
return msg.reply(embed(
`❌ Unknown target \`${target}\`.\nRun \`%reload\` with no arguments to see all reloadable targets.`
this.t(msg, "responses.reload.unknownTarget", { target })
));
}
+6 -6
View File
@@ -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
}
+6 -6
View File
@@ -18,8 +18,8 @@ export async function run(msg) {
if (guilds.length === 0) {
const emptyEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle("🌐 Servers (0)")
.setDescription("_No servers found._")
.setTitle(this.t(msg, "responses.servers.title", { count: 0 }))
.setDescription(this.t(msg, "responses.servers.noServers"))
;
return msg.reply({ embeds: [emptyEmbed] });
}
@@ -41,14 +41,14 @@ export async function run(msg) {
const buildPageContent = (pageIdx, expired = false) => {
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(`🌐 Servers (${guilds.length}) - Page ${pageIdx + 1}/${totalPages}`)
.setTitle(this.t(msg, "responses.servers.pageTitle", { count: guilds.length, page: pageIdx + 1, total: totalPages }))
.setDescription(pages[pageIdx])
.setFooter({
text: expired
? "⌛ Controls expired"
? this.t(msg, "responses._common.controlsExpired")
: totalPages > 1
? "💡 ⬅️ ➡️ Navigate"
: "List complete"
? this.t(msg, "responses._common.navigateHint")
: this.t(msg, "responses.servers.listComplete")
})
;
+47 -45
View File
@@ -25,8 +25,8 @@ const BOOL_FALSE = new Set(["false", "0", "no", "off", "disable", "disabled"]);
/** Settings whose values should be displayed as booleans */
const BOOL_SETTINGS = new Set(["songAnnouncements"]);
/** Valid locale codes */
const VALID_LOCALES = new Set(["en", "ar-SA", "ckb", "de-DE", "pt-BR"]);
/** Valid locale codes — populated from Locale instance at runtime */
let VALID_LOCALES = new Set(["en"]);
/** Volume constraints */
const VOLUME_MIN = 1;
@@ -149,17 +149,13 @@ async function handle247(ctx, message, value) {
if (!["off", "on", "auto"].includes(resolved)) {
return message.reply(embed(
`❌ Invalid value \`${value}\` for 24/7 mode.\n\n` +
`**Valid options:**\n` +
`• \`off\` — bot leaves after inactivity\n` +
`• \`on\` — bot stays active in the saved channel list\n` +
`• \`auto\` — bot stays active and keeps the saved channel list ready for recovery`
ctx.t(message, "responses.settings.invalid247", { value })
));
}
// ── OFF ───────────────────────────────────────────────────────────────────
if (resolved === "off") {
if (!guildId) return message.reply(embed("❌ Could not detect your server."));
if (!guildId) return message.reply(embed(ctx.t(message, "responses.settings.noServer")));
const channelId = ctx.players.checkVoiceChannels(message);
const channels = get247Channels(set);
@@ -186,7 +182,7 @@ async function handle247(ctx, message, value) {
const extra = remaining.length > 0
? `\nSaved channels left: ${remaining.map(ch => `<#${ch}>`).join(", ")}`
: "";
return message.reply(embed(`✅ 24/7 mode **disabled** for <#${id}>. Bot has left.${extra}`));
return message.reply(embed(ctx.t(message, "responses.settings.247Disabled", { channel: id }) + extra));
}
// Not in a channel — disable all for this guild
@@ -202,16 +198,16 @@ async function handle247(ctx, message, value) {
player.destroy();
}
}
return message.reply(embed("✅ 24/7 mode **disabled** for all channels in this server."));
return message.reply(embed(ctx.t(message, "responses.settings.247DisabledAll")));
}
// ── ON / AUTO ─────────────────────────────────────────────────────────────
if (!guildId) return message.reply(embed("❌ Could not detect your server."));
if (!guildId) return message.reply(embed(ctx.t(message, "responses.settings.noServer")));
const channelId = ctx.players.checkVoiceChannels(message);
if (!channelId) {
return message.reply(embed(
`❌ You're not in a voice channel. Join one first, then run \`%247 ${resolved}\` again.`
ctx.t(message, "responses.settings.noVoice247", { mode: resolved })
));
}
@@ -234,14 +230,14 @@ async function handle247(ctx, message, value) {
cleanId(p?._channelId ?? "") === id && cleanId(p?._guildId ?? "") === cleanId(guildId)
)
) {
return message.reply(embed(`✅ 24/7 mode set to ${modeLabel} for <#${id}>.\n${savedSummary}`));
return message.reply(embed(ctx.t(message, "responses.settings.247Set", { mode: modeLabel, channel: id, summary: savedSummary })));
}
try {
await ctx._spawnPlayer(guildId, id);
return message.reply(embed(`✅ 24/7 mode set to ${modeLabel} for <#${id}>. Bot joined!\n${savedSummary}`));
return message.reply(embed(ctx.t(message, "responses.settings.247Joined", { mode: modeLabel, channel: id, summary: savedSummary })));
} catch (e) {
return message.reply(embed(`✅ 24/7 mode saved for <#${id}>, but failed to join: ${e.message}\n${savedSummary}`));
return message.reply(embed(ctx.t(message, "responses.settings.247JoinFailed", { channel: id, error: e.message, summary: savedSummary })));
}
}
@@ -257,10 +253,7 @@ async function applySet(ctx, message, set, key, rawValue) {
if (BOOL_SETTINGS.has(key)) {
const bool = parseBool(rawValue);
if (bool === null) {
return (
`❌ \`${key}\` must be a boolean.\n` +
`Accepted: \`true\`, \`false\`, \`on\`, \`off\`, \`enable\`, \`disable\``
);
return ctx.t(message, "responses.settings.mustBeBool", { setting: key });
}
set.set(key, bool);
return null;
@@ -276,7 +269,7 @@ async function applySet(ctx, message, set, key, rawValue) {
if (key === "volume") {
const num = parseInt(rawValue, 10);
if (isNaN(num) || num < VOLUME_MIN || num > VOLUME_MAX) {
return `❌ Volume must be a number between **${VOLUME_MIN}** and **${VOLUME_MAX}**.`;
return ctx.t(message, "responses.settings.volumeRange");
}
set.set(key, num);
return null;
@@ -285,22 +278,26 @@ async function applySet(ctx, message, set, key, rawValue) {
// Locale
if (key === "locale") {
if (!VALID_LOCALES.has(rawValue)) {
return (
`❌ \`${rawValue}\` is not a supported locale.\n` +
`Available locales: ${[...VALID_LOCALES].map(l => `\`${l}\``).join(", ")}`
);
return ctx.t(message, "responses.settings.invalidLocale", {
locale: rawValue,
locales: [...VALID_LOCALES].map(l => `\`${l}\``).join(", ")
});
}
set.set(key, rawValue);
// Invalidate locale cache so the new locale takes effect immediately
// without requiring a bot reboot.
const guildId = getGuildId(message);
if (guildId) ctx.locale.invalidateCache(guildId);
return null;
}
// Prefix
if (key === "prefix") {
if (!rawValue || rawValue.length > 5) {
return `❌ Prefix must be between **1** and **5** characters.`;
return ctx.t(message, "responses.settings.prefixLength");
}
if (/\s/.test(rawValue)) {
return `❌ Prefix cannot contain spaces.`;
return ctx.t(message, "responses.settings.prefixSpaces");
}
}
@@ -322,7 +319,7 @@ async function handleShortcut(ctx, message, settingKey, valueTokens) {
// GET (no value provided)
if (valueTokens.length === 0) {
if (settingKey === "stay_247") {
return message.reply(embed(`24/7 mode: ${format247Status(set)}`));
return message.reply(embed(ctx.t(message, "responses.settings.247Status", { status: format247Status(set) })));
}
const val = set.get(settingKey);
return message.reply(embed(`\`${settingKey}\` → ${displayValue(settingKey, val)}`));
@@ -336,13 +333,19 @@ async function handleShortcut(ctx, message, settingKey, valueTokens) {
// handle247 replies on its own
if (settingKey !== "stay_247") {
const val = set.get(settingKey);
return message.reply(embed(`✅ \`${settingKey}\` set to ${displayValue(settingKey, val)}`));
return message.reply(embed(ctx.t(message, "responses.settings.setSuccess", { label: settingKey, value: displayValue(settingKey, val) })));
}
}
// ── Command definition ────────────────────────────────────────────────────────
export const command = function() {
// Populate valid locales from the Locale instance so the list stays
// in sync when new locale files are added to storage/locales/bot/.
if (this.locale) {
VALID_LOCALES = this.locale.availableLocales();
}
if (this.loader) {
for (const [alias, settingKey] of Object.entries(SHORTCUTS)) {
const builder = new CommandBuilder()
@@ -470,7 +473,7 @@ export async function run(message, data) {
if (!this.settingsMgr.isOption(settingKey)) {
const available = Object.keys(this.settingsMgr.defaults).join("`, `");
return message.reply(embed(
`❌ Unknown setting \`${settingKey}\`.\nAvailable: \`${available}\``
this.t(message, "responses.settings.unknownSetting", { setting: settingKey }) + "\n" + this.t(message, "responses.settings.availableSettings", { settings: available })
));
}
@@ -480,7 +483,7 @@ export async function run(message, data) {
if (settingKey === "stay_247") return; // handle247 replied already
const newVal = set.get(settingKey);
return message.reply(embed(`✅ **${prettifySettingLabel(settingKey)}** set to ${displayValue(settingKey, newVal)}`));
return message.reply(embed(this.t(message, "responses.settings.setSuccess", { label: prettifySettingLabel(settingKey), value: displayValue(settingKey, newVal) })));
}
// ── get ───────────────────────────────────────────────────────────────────
@@ -516,22 +519,26 @@ export async function run(message, data) {
});
return message.reply(embed(
`Server: **${guildName}**\n\n${lines.join("\n")}\n\n` +
`Shortcuts: \`${prefix}247\`, \`${prefix}prefix\`\n` +
`Use \`${prefix}settings help <setting>\` to learn about any setting.`,
{ title: "⚙️ Server Settings", iconURL: iconUrl }
this.t(message, "responses.settings.serverHeader", { name: guildName }) + "\n\n" + lines.join("\n") + "\n\n" +
this.t(message, "responses.settings.shortcutsHint", { prefix }),
{ title: this.t(message, "responses.settings.serverTitle"), iconURL: iconUrl }
));
}
// ── reset ─────────────────────────────────────────────────────────────────
if (cmd === "resetSettings") {
if (!this.settingsMgr.isOption(settingKey)) {
return message.reply(embed(`❌ Unknown setting \`${settingKey}\`.`));
return message.reply(embed(this.t(message, "responses.settings.unknownSetting", { setting: settingKey })));
}
set.reset(settingKey);
// Invalidate locale cache if the locale setting was reset
if (settingKey === "locale") {
const guildId = getGuildId(message);
if (guildId) this.locale.invalidateCache(guildId);
}
const def = set.get(settingKey);
return message.reply(embed(
`🔄 \`${settingKey}\` has been reset to its default: ${displayValue(settingKey, def)}`
this.t(message, "responses.settings.resetSuccess", { setting: settingKey, value: displayValue(settingKey, def) })
));
}
@@ -543,15 +550,10 @@ export async function run(message, data) {
const keys = Object.keys(this.settingsMgr.defaults);
const keyList = keys.map(k => `\`${k}\``).join(", ");
return message.reply(embed(
`**⚙️ Settings Help**\n\n` +
`**Available settings:** ${keyList}\n\n` +
`**Subcommands:**\n` +
`• \`${pfx}settings get\` — list all current values\n` +
`• \`${pfx}settings get <setting>\` — view a single setting\n` +
`• \`${pfx}settings set <setting> <value>\` — change a setting\n` +
`• \`${pfx}settings reset <setting>\` — restore default value\n` +
`• \`${pfx}settings help <setting>\` — describe a setting\n\n` +
`**Shortcuts:** \`${pfx}prefix\`, \`${pfx}247\``,
this.t(message, "responses.settings.helpTitle") + "\n\n" +
this.t(message, "responses.settings.helpAvailable", { settings: keyList }) + "\n\n" +
this.t(message, "responses.settings.helpSubcommands", { prefix: pfx }) + "\n\n" +
this.t(message, "responses.settings.helpShortcuts", { prefix: pfx }),
{ title: "⚙️ Settings Help" }
));
}
+2 -2
View File
@@ -23,8 +23,8 @@ export async function run(message) {
}
const desc = skippedTitle
? `⏭️ Skipped [${skippedTitle}](${skippedLink})`
: "⏭️ Skipped";
? this.t(message, "responses.skip.skippedTrack", { title: skippedTitle, url: skippedLink })
: this.t(message, "responses.skip.skipped");
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
+14 -14
View File
@@ -89,28 +89,28 @@ function getLivePlayerCount(playerMap) {
// ── Embed builder ─────────────────────────────────────────────────────────────
function buildEmbed({ guildCount, userCount, playerCount, ping, uptime, comHash, comLink, reason, footer, loading }) {
function buildEmbed(t, msg, { guildCount, userCount, playerCount, ping, uptime, comHash, comLink, reason, footer, loading }) {
const num = (v) => Utils.formatNumber(v);
const ld = (v) => loading ? "..." : v;
const description = [
`📂 **Servers** — \`${num(guildCount)}\``,
`👥 **Users** — \`${ld(num(userCount))}\``,
`🎧 **Players** — \`${num(playerCount)}\``,
`🏓 **Ping** — \`${ld(`${num(ping)}ms`)}\``,
`⏱️ **Uptime** — \`${uptime}\``,
`🔧 **Build** — [\`${comHash}\`](${comLink})`,
reason ? `🪛 **Last restart** — \`${reason}\`` : null,
`${t(msg, "responses.stats.servers")} — \`${num(guildCount)}\``,
`${t(msg, "responses.stats.users")} — \`${ld(num(userCount))}\``,
`${t(msg, "responses.stats.players")} — \`${num(playerCount)}\``,
`${t(msg, "responses.stats.ping")} — \`${ld(`${num(ping)}ms`)}\``,
`${t(msg, "responses.stats.uptime")} — \`${uptime}\``,
`${t(msg, "responses.stats.build")} — [\`${comHash}\`](${comLink})`,
reason ? `${t(msg, "responses.stats.lastRestart")} — \`${reason}\`` : null,
``,
`☕ [Support us on Ko-fi](https://ko-fi.com/remixbot)`,
`💬 [Community](https://fluxer.gg/Remix)`,
t(msg, "responses.stats.supportKofi"),
t(msg, "responses.stats.community"),
].filter(l => l !== null).join("\n");
const builder = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: "Remix Music Bot" })
.setAuthor({ name: t(msg, "responses.stats.title") })
.setDescription(description)
.setFooter({ text: footer || "Remix Music Bot" });
.setFooter({ text: footer || t(msg, "responses.stats.title") });
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
return builder;
@@ -134,13 +134,13 @@ export async function run(message) {
// Measure real round-trip latency
const start = Date.now();
const msg = await message.reply({
embeds: [buildEmbed({ ...shared, userCount: hasCached ? cachedUserCount : 0, ping: 0, loading: !hasCached })]
embeds: [buildEmbed((...a) => this.t(...a), message, { ...shared, userCount: hasCached ? cachedUserCount : 0, ping: 0, loading: !hasCached })]
});
const ping = Date.now() - start;
const users = await getUserCount(this.client);
await msg.edit({
embeds: [buildEmbed({ ...shared, userCount: users, ping, loading: false })]
embeds: [buildEmbed((...a) => this.t(...a), message, { ...shared, userCount: users, ping, loading: false })]
}).catch((err) => console.error("[stats] editEmbed failed:", err));
}
+2 -4
View File
@@ -11,11 +11,9 @@ export const command = new CommandBuilder()
export function run(msg) {
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle("💬 Support")
.setTitle(this.t(msg, "responses.support.title"))
.setDescription(
"For anything regarding Remix, head over to our server:\n" +
"[Remix HQ](https://fluxer.gg/remix)\n\n" +
"If you don't want to join, feel free to contact the team members listed in the server."
this.t(msg, "responses.support.description")
)
;
msg.reply({ embeds: [embed] });
+4 -4
View File
@@ -10,7 +10,7 @@ export const command = new CommandBuilder()
export async function run(msg, data) {
const guild = msg.channel?.channel?.guild ?? msg.message?.guild;
if (!guild) {
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ Must be used in a server.");
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.test.notInServer"));
return msg.reply({ embeds: [embed] });
}
@@ -26,7 +26,7 @@ export async function run(msg, data) {
}
if (channelCounts.size === 0) {
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("No one is in voice.");
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.test.noOneInVoice"));
return msg.reply({ embeds: [embed] });
}
@@ -51,12 +51,12 @@ export async function run(msg, data) {
let desc = "";
for (const [channelId, total] of channelCounts) {
const name = await getChannelName(channelId);
desc += `🔊 **${name}**: ${total} member${total !== 1 ? "s" : ""}\n`;
desc += this.t(msg, "responses.test.channelEntry", { name, count: total });
}
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle("🎙️ Voice Channel Members")
.setTitle(this.t(msg, "responses.test.title"))
.setDescription(desc.trim())
;
msg.reply({ embeds: [embed] });
+3 -3
View File
@@ -26,14 +26,14 @@ export async function run(message, data) {
if (!volOption || raw == null || isNaN(Number(raw))) {
const current = Math.round((p.preferredVolume ?? 1) * 100);
embed.setDescription(`🔊 Current volume: \`${current}%\``);
embed.setDescription(this.t(message, "responses.volume.current", { volume: current }));
} else {
const pct = Number(raw);
if (pct < 0 || pct > MAX_VOLUME) {
embed.setDescription(`❌ Volume must be between \`0\` and \`${MAX_VOLUME}%\`.`);
embed.setDescription(this.t(message, "responses.volume.outOfRange", { max: MAX_VOLUME }));
} else {
p.setVolume(pct / 100);
embed.setDescription(`🔊 Volume changed to \`${pct}%\` for this session.`);
embed.setDescription(this.t(message, "responses.volume.changed", { volume: pct }));
}
}
+9 -8
View File
@@ -38,25 +38,26 @@ export async function run(message, data) {
if (!volOption || raw === null || raw === undefined || isNaN(Number(raw))) {
const currentDefault = set?.get("volume") ?? 100;
const currentPlayerVol = Math.round((p.preferredVolume ?? 1) * 100);
const pfx = set?.get("prefix") ?? "%";
embed
.setTitle("🔊 Volume Settings")
.setTitle(this.t(message, "responses.volumedefault.title"))
.setDescription(
`• Server default: \`${currentDefault}%\`\n` +
`• Current player volume: \`${currentPlayerVol}%\`\n\n` +
this.t(message, "responses.volumedefault.serverDefault", { volume: currentDefault }) + "\n" +
this.t(message, "responses.volumedefault.currentVolume", { volume: currentPlayerVol }) + "\n\n" +
(hasManage
? `To change the default, use: \`${set?.get("prefix") ?? "%"}volumedefault <0-${MAX_VOLUME}>\``
: `⚠️ You need **Manage Server** permission to change the default.`)
? this.t(message, "responses.volumedefault.changeHint", { prefix: pfx, max: MAX_VOLUME })
: this.t(message, "responses.volumedefault.noPermission"))
);
} else if (!hasManage) {
embed.setDescription("❌ You need **Manage Server** permission to set the server default volume.");
embed.setDescription(this.t(message, "responses.volumedefault.noPermissionSet"));
} else {
const pct = Number(raw);
if (pct < 0 || pct > MAX_VOLUME) {
embed.setDescription(`❌ Volume must be between \`0\` and \`${MAX_VOLUME}%\`.`);
embed.setDescription(this.t(message, "responses.volumedefault.outOfRange", { max: MAX_VOLUME }));
} else {
p.setVolume(pct / 100);
if (set) set.set("volume", pct);
embed.setDescription(`🔊 Server default volume saved as \`${pct}%\`.`);
embed.setDescription(this.t(message, "responses.volumedefault.saved", { volume: pct }));
}
}