mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
i18n: replace hardcoded strings with locale keys across all commands
- Add locale keys for gateway/MessageHandler permission error messages
- Add locale support to settings command (prettifySettingLabel now accepts t/guildId)
- Replace all hardcoded strings in player, search, seek, trackopt, vote, autoplay, debug, lastfm commands with this.t() calls
- Add new locale keys: command suggestions, vote descriptions, debug pagination, lastfm auth/link/profile/whoknows/leaderboard/playlists/artists strings
- Fix typos in en.json: broken backtick in alreadyLinked, extra $ in unlovedTrack artist template
- Add new locale key for command suggestion ("Did you mean...?")
- Remove "React to refresh" suffix from controls expired footer (now just uses locale key)
This commit is contained in:
1 parent
b581722c46
commit
eeb27de9bb
19 files changed
+1476
-5862
No files matched your search
@@ -89,11 +89,10 @@ export async function run(msg, data) {
|
||||
p.on("queueEnd", p._autoplayHandler);
|
||||
}
|
||||
|
||||
const lfStatus = this.lastfm?.enabled ? " with Last.fm recommendations" : " using YouTube search";
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(`🔁 Autoplay **enabled**${lfStatus} — similar tracks will be added automatically when the queue ends.`)]
|
||||
.setDescription(this.t(msg, "responses.autoplay.enabled"))]
|
||||
});
|
||||
} else {
|
||||
if (p._autoplayHandler) {
|
||||
@@ -104,7 +103,7 @@ export async function run(msg, data) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(`➡️ Autoplay **disabled** — the bot will stop when the queue ends.`)]
|
||||
.setDescription(this.t(msg, "responses.autoplay.disabled"))]
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -121,8 +121,8 @@ export async function run(msg, data) {
|
||||
? "Summary"
|
||||
: `Player Detail${pages[pageIdx].includes(",") ? "s" : ""}`;
|
||||
const footerText = expired
|
||||
? "Controls expired"
|
||||
: `Page ${pageIdx + 1}/${totalPages} • Use ⬅️➡️ to navigate`;
|
||||
? this.t(msg, "responses._common.controlsExpired")
|
||||
: `${this.t(msg, "responses.eval.pageLabel", { page: pageIdx + 1, total: totalPages })} • ${this.t(msg, "responses.eval.navigateHint")}`;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
|
||||
+163
-172
File diff suppressed because it is too large.
Load diff
+7
-7
@@ -92,9 +92,9 @@ export async function run(msg) {
|
||||
const volumeBar = "█".repeat(volBars) + "░".repeat(10 - volBars);
|
||||
|
||||
const queueSize = player.queue.size();
|
||||
const loopStatus = player.queue.songLoop ? "🔂 Song" : player.queue.loop ? "🔁 Queue" : "❌ Off";
|
||||
const loopStatus = player.queue.songLoop ? this.t(msg, "responses.player.loopSong") : player.queue.loop ? this.t(msg, "responses.player.loopQueue") : this.t(msg, "responses.player.loopOff");
|
||||
|
||||
let filterStatus = "🔇 Off";
|
||||
let filterStatus = this.t(msg, "responses.player.filterOff");
|
||||
if (player.activeFilter) {
|
||||
if (player.activeFilter.label.includes("+")) {
|
||||
filterStatus = `🔥 **${player.activeFilter.label}**`;
|
||||
@@ -114,8 +114,8 @@ export async function run(msg) {
|
||||
`${progressBar}`,
|
||||
`${timeDisplay}`,
|
||||
``,
|
||||
`🔊 Volume: \`${volPercent}%\` ${volumeBar}`,
|
||||
`📋 Queue: \`${queueSize}\` tracks | Loop: ${loopStatus} | Filter: ${filterStatus}`,
|
||||
this.t(msg, "responses.player.volumeLabel", { volume: volPercent }) + " " + volumeBar,
|
||||
`${this.t(msg, "responses.player.queueLabel", { count: queueSize })} | Loop: ${loopStatus} | Filter: ${filterStatus}`,
|
||||
``,
|
||||
state.message ? `💬 *${state.message}*` : `💡 *${this.t(msg, "responses.player.reactHint")}*`,
|
||||
``,
|
||||
@@ -177,7 +177,7 @@ export async function run(msg) {
|
||||
emojiRemoveTimeout = setTimeout(async () => {
|
||||
await clearReactions();
|
||||
const disabledEmbed = buildEmbed({ message: this.t(msg, "responses.player.controlsDisabled") });
|
||||
disabledEmbed.footer = { text: this.t(msg, "responses._common.controlsExpired") + " • React to refresh" };
|
||||
disabledEmbed.footer = { text: this.t(msg, "responses._common.controlsExpired") };
|
||||
await message.edit({ embeds: [disabledEmbed] }).catch(() => {});
|
||||
}, EMOJI_REMOVE_TIMEOUT);
|
||||
};
|
||||
@@ -294,7 +294,7 @@ export async function run(msg) {
|
||||
try {
|
||||
switch (control.action) {
|
||||
case "previous":
|
||||
reply = "Previous track is not available yet.";
|
||||
reply = this.t(msg, "responses.player.previousNotAvailable");
|
||||
break;
|
||||
|
||||
case "resume":
|
||||
@@ -491,7 +491,7 @@ export async function run(msg) {
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
reply = `⚠️ Error: ${err.message}`;
|
||||
reply = this.t(msg, "responses.player.errorGeneric", { error: err.message });
|
||||
}
|
||||
|
||||
if (shouldUpdate) refresh({ message: reply });
|
||||
|
||||
+5
-5
@@ -72,7 +72,7 @@ export async function run(msg, data) {
|
||||
|
||||
const nativeMsg = msg.message ?? msg;
|
||||
const rawMsg = await nativeMsg.reply(
|
||||
{ embeds: [makeEmbed(this.t(msg, "responses.search.loadingResults"), this.t(msg, "responses.play.searchingProvider", { provider: name }), `Searching ${name}...`)] },
|
||||
{ embeds: [makeEmbed(this.t(msg, "responses.search.loadingResults"), this.t(msg, "responses.play.searchingProvider", { provider: name }), this.t(msg, "responses.search.resultsTitle", { provider: name }))]},
|
||||
{ ping: false }
|
||||
).catch(() => null);
|
||||
if (!rawMsg) return;
|
||||
@@ -99,7 +99,7 @@ export async function run(msg, data) {
|
||||
embeds: [makeEmbed(
|
||||
desc,
|
||||
this.t(msg, "responses.search.reactHint"),
|
||||
`${name} — Search Results`
|
||||
this.t(msg, "responses.search.resultsTitle", { provider: name })
|
||||
)]
|
||||
}).catch(() => {});
|
||||
|
||||
@@ -131,7 +131,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (e.emoji_id === CANCEL_EMOJI) {
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.cancelled"), null, `${name} — Search Results`)]
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.cancelled"), null, this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
||||
}).catch(() => {});
|
||||
return;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ export async function run(msg, data) {
|
||||
embeds: [makeEmbed(
|
||||
this.t(msg, "responses.search.added", { title: v.title, url: v.url }),
|
||||
null,
|
||||
`${name} — Search Results`
|
||||
this.t(msg, "responses.search.resultsTitle", { provider: name })
|
||||
)]
|
||||
}).catch(() => {});
|
||||
});
|
||||
@@ -156,7 +156,7 @@ export async function run(msg, data) {
|
||||
unobserve();
|
||||
clearReactions().catch(() => {});
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.timedOut"), this.t(msg, "responses.search.sessionClosed"), `${name} — Search Results`)]
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.timedOut"), this.t(msg, "responses.search.sessionClosed"), this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
||||
}).catch(() => {});
|
||||
}, SESSION_MS);
|
||||
}
|
||||
+7
-7
@@ -19,23 +19,23 @@ export async function run(msg, data) {
|
||||
if (!p) return;
|
||||
|
||||
if (!p.queue?.getCurrent()) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ There's nothing playing at the moment!")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.nothingPlaying"))] });
|
||||
}
|
||||
|
||||
if (p._paused) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Can't seek while paused. Resume first.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.paused"))] });
|
||||
}
|
||||
|
||||
let seekMs = parseSeekPosition(positionInput);
|
||||
if (seekMs === null || seekMs < 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Invalid position format. Use \`mm:ss\`, \`hh:mm:ss\`, or seconds (e.g. \`1:30\`, \`90\`, \`0:30\`).`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
||||
}
|
||||
|
||||
const trackDuration = p._getTrackDurationMs(p.queue.getCurrent());
|
||||
|
||||
if (trackDuration > 0 && seekMs >= trackDuration) {
|
||||
const maxStr = formatDuration(trackDuration);
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Position exceeds track duration (**${maxStr}**). Use a value between \`0:00\` and \`${maxStr}\`.`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.exceedsDuration", { duration: maxStr }))] });
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -43,12 +43,12 @@ export async function run(msg, data) {
|
||||
if (result) {
|
||||
const seekStr = formatDuration(seekMs);
|
||||
const totalStr = trackDuration > 0 ? formatDuration(trackDuration) : "∞";
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`⏩ Seeked to **${seekStr}** / ${totalStr}`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.seek.seeked", { position: seekStr }))] });
|
||||
} else {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Seeking is not supported by the current audio node.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.notSupported"))] });
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Failed to seek: ${err.message}`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.failed", { error: err.message }))] });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-6
@@ -385,8 +385,20 @@ function format247Summary(set, t, guildId) {
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
function prettifySettingLabel(key) {
|
||||
const custom = {
|
||||
function prettifySettingLabel(key, t, guildId) {
|
||||
const localeMap = {
|
||||
songAnnouncements: "responses.settings.labelSongAnnouncements",
|
||||
prefix: "responses.settings.labelPrefix",
|
||||
pfx: "responses.settings.labelPfp",
|
||||
locale: "responses.settings.labelLocale",
|
||||
stay_247: "responses.settings.label247",
|
||||
volume: "responses.settings.labelVolume",
|
||||
announcementChannelId: "responses.settings.labelAnnouncementChannel",
|
||||
restrictVolume: "responses.settings.labelRestrictVolume",
|
||||
autojoin_channel: "responses.settings.labelAutojoinChannel"
|
||||
};
|
||||
if (localeMap[key] && t && guildId) return t(guildId, localeMap[key]);
|
||||
const fallback = {
|
||||
songAnnouncements: "Song announcements",
|
||||
prefix: "Prefix",
|
||||
pfx: "Bot avatar style",
|
||||
@@ -397,7 +409,7 @@ function prettifySettingLabel(key) {
|
||||
restrictVolume: "Restrict volume",
|
||||
autojoin_channel: "Autojoin channel"
|
||||
};
|
||||
return custom[key] ?? key.replace(/_/g, " ");
|
||||
return fallback[key] ?? key.replace(/_/g, " ");
|
||||
}
|
||||
|
||||
async function handle247(ctx, message, value) {
|
||||
@@ -483,8 +495,7 @@ async function handle247(ctx, message, value) {
|
||||
const channels = get247Channels(set);
|
||||
if (!channels.has(id) && channels.size >= MAX_247_CHANNELS) {
|
||||
return message.reply(embed(
|
||||
`You can save up to ${MAX_247_CHANNELS} 24/7 voice channels in one server. ` +
|
||||
`Use \`${set.get("prefix") ?? "%"}247 off\` in one of the saved channels first.`
|
||||
ctx.t(message, "responses.settings.max247Channels", { max: MAX_247_CHANNELS, prefix: set.get("prefix") ?? "%" })
|
||||
));
|
||||
}
|
||||
channels.add(id);
|
||||
@@ -806,7 +817,7 @@ export async function run(message, data) {
|
||||
));
|
||||
}
|
||||
|
||||
const description = this.settingsMgr.descriptions?.[settingKey] ?? "No description available.";
|
||||
const description = this.settingsMgr.descriptions?.[settingKey] ?? this.t(message, "responses.settings.noDescription");
|
||||
const currentVal = set.get(settingKey);
|
||||
const defaultVal = this.settingsMgr.defaults?.[settingKey];
|
||||
|
||||
|
||||
+33
-35
@@ -94,7 +94,7 @@ function extractAlias(parts) {
|
||||
export async function run(msg, data) {
|
||||
const trackOpts = this.trackOptions;
|
||||
if (!trackOpts) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Track options feature is not available.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notAvailable"))] });
|
||||
}
|
||||
|
||||
const subCommand = data.command.name || data.commandId || "get";
|
||||
@@ -104,18 +104,20 @@ export async function run(msg, data) {
|
||||
|
||||
const current = p.queue?.getCurrent();
|
||||
if (!current && subCommand !== "list") {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ There's nothing playing at the moment!")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.nothingPlaying"))] });
|
||||
}
|
||||
|
||||
const userId = msg.message?.author?.id ?? msg.author?.id;
|
||||
if (!userId) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Could not identify your user.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses._common.noVoiceChannel"))] });
|
||||
}
|
||||
|
||||
const prefix = this.handler?.getPrefix?.(msg.message?.guildId) ?? "%";
|
||||
|
||||
if (subCommand === "set") {
|
||||
const timesRaw = data.get("times")?.value;
|
||||
if (!timesRaw) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Provide start and optional end time. Usage: `%trackopt set 0:30` or `%trackopt set 0:30 3:45 alias:hidden`")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
}
|
||||
|
||||
const parts = timesRaw.trim().split(/\s+/);
|
||||
@@ -123,44 +125,41 @@ export async function run(msg, data) {
|
||||
|
||||
const startMs = parseTimeInput(parts[0]);
|
||||
if (startMs === null || startMs < 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Invalid start time format. Use `mm:ss`, `hh:mm:ss`, or seconds.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
}
|
||||
|
||||
let endMs = 0;
|
||||
if (parts.length > 1) {
|
||||
endMs = parseTimeInput(parts[1]);
|
||||
if (endMs === null || endMs <= 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Invalid end time format. Use `mm:ss`, `hh:mm:ss`, or seconds.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
}
|
||||
if (endMs <= startMs) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ End time must be after start time.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidEndAfterStart"))] });
|
||||
}
|
||||
}
|
||||
|
||||
const trackDuration = p._getTrackDurationMs(current);
|
||||
if (trackDuration > 0) {
|
||||
if (startMs >= trackDuration) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Start time exceeds track duration (**${formatMs(trackDuration)}**).`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.startExceedsDuration", { duration: formatMs(trackDuration) }))] });
|
||||
}
|
||||
if (endMs > 0 && endMs > trackDuration) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ End time exceeds track duration (**${formatMs(trackDuration)}**).`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.endExceedsDuration", { duration: formatMs(trackDuration) }))] });
|
||||
}
|
||||
}
|
||||
|
||||
const result = await trackOpts.set(userId, current, startMs, endMs, aliasRaw);
|
||||
if (!result) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Failed to save track option.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.saveFailed"))] });
|
||||
}
|
||||
|
||||
const aliasLabel = result.alias === DEFAULT_ALIAS ? "" : ` [${result.alias}]`;
|
||||
let desc = `✅ Track option saved for **${current.title}**${aliasLabel}\n`;
|
||||
desc += `▶️ Start: **${formatMs(startMs)}**`;
|
||||
if (endMs > 0) desc += ` | ⏹️ End: **${formatMs(endMs)}**`;
|
||||
else desc += ` | ⏹️ End: **full track**`;
|
||||
const endLabel = endMs > 0 ? formatMs(endMs) : "full track";
|
||||
let desc;
|
||||
if (result.alias === DEFAULT_ALIAS) {
|
||||
desc += `\n\nThis will apply automatically whenever this track plays in a channel you're in.`;
|
||||
desc = this.t(msg, "responses.trackopt.saved", { title: current.title, aliasLabel: "", start: formatMs(startMs), end: endLabel });
|
||||
} else {
|
||||
desc += `\n\nUse \`%trackopt play ${result.alias}\` to apply this trim while the track is playing.`;
|
||||
desc = this.t(msg, "responses.trackopt.savedAlias", { title: current.title, alias: result.alias, start: formatMs(startMs), end: endLabel, prefix });
|
||||
}
|
||||
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] });
|
||||
@@ -169,15 +168,15 @@ export async function run(msg, data) {
|
||||
if (subCommand === "get") {
|
||||
const rows = await trackOpts.getAllForTrack(userId, current);
|
||||
if (!rows || rows.length === 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`No custom times set for **${current.title}**.`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notSet", { title: current.title }))] });
|
||||
}
|
||||
|
||||
let desc = `📎 Track options for **${current.title}** (${rows.length})\n\n`;
|
||||
let desc = this.t(msg, "responses.trackopt.current", { title: current.title, count: rows.length }) + "\n\n";
|
||||
for (const row of rows) {
|
||||
const aliasLabel = row.alias === DEFAULT_ALIAS ? "default" : row.alias;
|
||||
const endStr = row.end_ms > 0 ? formatMs(row.end_ms) : "end";
|
||||
const autoTag = row.alias === DEFAULT_ALIAS ? " ← auto" : "";
|
||||
desc += `• **${aliasLabel}** — ${formatMs(row.start_ms)} → ${endStr}${autoTag}\n`;
|
||||
desc += this.t(msg, "responses.trackopt.currentEntry", { alias: aliasLabel, start: formatMs(row.start_ms), end: endStr, autoTag }) + "\n";
|
||||
}
|
||||
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] });
|
||||
@@ -186,12 +185,12 @@ export async function run(msg, data) {
|
||||
if (subCommand === "play") {
|
||||
const aliasRaw = data.get("alias")?.value;
|
||||
if (!aliasRaw) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Provide an alias name. Usage: `%trackopt play hidden`")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.provideAlias", { prefix }))] });
|
||||
}
|
||||
|
||||
const safeAlias = aliasRaw.toLowerCase().replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 32);
|
||||
if (!safeAlias) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Invalid alias name. Use letters, numbers, hyphens, or underscores.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidAlias"))] });
|
||||
}
|
||||
|
||||
const result = await trackOpts.get(userId, current, safeAlias);
|
||||
@@ -199,26 +198,26 @@ export async function run(msg, data) {
|
||||
const allAliases = await trackOpts.getAllForTrack(userId, current);
|
||||
if (allAliases.length > 0) {
|
||||
const names = allAliases.map(r => r.alias === DEFAULT_ALIAS ? "default" : r.alias).join(", ");
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ No alias **${safeAlias}** found for **${current.title}**.\nYour aliases: ${names}`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.aliasNotFound", { alias: safeAlias, title: current.title, names }))] });
|
||||
}
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ No alias **${safeAlias}** found for **${current.title}**.`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notFound", { title: current.title }))] });
|
||||
}
|
||||
|
||||
if (!p.connection || p._paused) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ The player must be actively playing to apply an alias.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.mustBePlaying"))] });
|
||||
}
|
||||
|
||||
try {
|
||||
const applied = await p.applyTrackOption(result);
|
||||
if (!applied) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Failed to apply alias.")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.applyFailed", { error: "Unknown error" }))] });
|
||||
}
|
||||
|
||||
const aliasLabel = safeAlias === DEFAULT_ALIAS ? "default" : safeAlias;
|
||||
const endStr = result.endMs > 0 ? formatMs(result.endMs) : "end";
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`✂️ Applied alias **${aliasLabel}** — ${formatMs(result.startMs)} → ${endStr}`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.applied", { alias: aliasLabel, start: formatMs(result.startMs), end: endStr }))] });
|
||||
} catch (e) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Failed to apply alias: ${e.message}`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.applyFailed", { error: e.message }))] });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,22 +225,21 @@ export async function run(msg, data) {
|
||||
const aliasRaw = data.get("alias")?.value;
|
||||
const removed = await trackOpts.remove(userId, current, aliasRaw || null);
|
||||
if (!removed) {
|
||||
const aliasLabel = aliasRaw ? ` **${aliasRaw}**` : "";
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`No custom times found${aliasLabel} for **${current.title}**.`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notFound", { title: current.title }))] });
|
||||
}
|
||||
if (aliasRaw) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`🗑️ Removed alias **${aliasRaw}** for **${current.title}**.`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.removedAlias", { alias: aliasRaw, title: current.title }))] });
|
||||
}
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`🗑️ Removed all track options for **${current.title}**.`)] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.removedAll", { title: current.title }))] });
|
||||
}
|
||||
|
||||
if (subCommand === "list") {
|
||||
const rows = await trackOpts.list(userId);
|
||||
if (!rows || rows.length === 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription("📭 You have no saved track options. Use `%trackopt set <start> [end]` to add one!")] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.listEmpty", { prefix }))] });
|
||||
}
|
||||
|
||||
let desc = `📋 **Your Track Options** (${rows.length})\n\n`;
|
||||
let desc = this.t(msg, "responses.trackopt.listTitle", { count: rows.length }) + "\n\n";
|
||||
let lastTrack = "";
|
||||
for (const row of rows) {
|
||||
const title = row.track_title || row.track_identifier;
|
||||
@@ -255,7 +253,7 @@ export async function run(msg, data) {
|
||||
const autoTag = row.alias === DEFAULT_ALIAS ? " ← auto" : "";
|
||||
desc += ` • ${aliasLabel}: ${formatMs(row.start_ms)} → ${endStr}${autoTag}\n`;
|
||||
}
|
||||
desc += `\nUse \`%trackopt play <alias>\` to apply a named trim, or \`%trackopt remove [alias]\` to delete one.`;
|
||||
desc += "\n" + this.t(msg, "responses.trackopt.listHint", { prefix });
|
||||
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] });
|
||||
}
|
||||
|
||||
+32
-45
@@ -34,19 +34,19 @@ export const command = new CommandBuilder()
|
||||
.setRequired(false)
|
||||
);
|
||||
|
||||
function notConfigured(prefix) {
|
||||
function notConfigured(prefix, t, guildId) {
|
||||
return {
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setDescription(`FluxerList integration is not configured on this bot. Ask the bot owner to add a FluxerList API key to the config.`)]
|
||||
.setDescription(t(guildId, "responses.vote.notConfigured"))]
|
||||
};
|
||||
}
|
||||
|
||||
function noResourceId(type, prefix) {
|
||||
function noResourceId(type, prefix, t, guildId) {
|
||||
return {
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setDescription(`No ${type} ID configured. Provide it with \`${prefix}vote check ${type} <id-or-slug>\` or set it in config.json.`)]
|
||||
.setDescription(t(guildId, "responses.vote.noResourceId", { type, prefix }))]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,29 +61,29 @@ function noResourceId(type, prefix) {
|
||||
* @param {boolean} expired - Whether the navigation controls have expired
|
||||
* @returns {object} Embed payload
|
||||
*/
|
||||
function buildVotersEmbed(voters, total, page, limit, type, resourceId, expired = false) {
|
||||
function buildVotersEmbed(voters, total, page, limit, type, resourceId, expired = false, t, guildId) {
|
||||
const totalPages = Math.max(1, Math.ceil(total / limit));
|
||||
|
||||
const lines = voters.map((v, i) => {
|
||||
const rank = (page - 1) * limit + i + 1;
|
||||
const num = String(rank).padStart(2, " ");
|
||||
const username = v.username || `User#${v.fluxerId}`;
|
||||
const username = v.username || t(guildId, "responses.vote.unknownUser", { id: v.fluxerId });
|
||||
const dateStr = v.votedAt
|
||||
? new Date(v.votedAt).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })
|
||||
: "Unknown";
|
||||
return `\`${num}.\` **${username}** — voted ${dateStr}`;
|
||||
: t(guildId, "responses.vote.unknownDate");
|
||||
return `\`${num}.\` **${username}** — ${t(guildId, "responses.vote.votedDate", { date: dateStr })}`;
|
||||
});
|
||||
|
||||
const desc = lines.length > 0
|
||||
? lines.join("\n").slice(0, 4096)
|
||||
: "No voters found on this page.";
|
||||
: t(guildId, "responses.vote.noVotersOnPage");
|
||||
|
||||
const title = type === "server" ? "Server Voters" : "Bot Voters";
|
||||
const title = type === "server" ? t(guildId, "responses.vote.serverVoters") : t(guildId, "responses.vote.botVoters");
|
||||
const footerText = expired
|
||||
? "Controls expired"
|
||||
? t(guildId, "responses.vote.controlsExpired")
|
||||
: totalPages > 1
|
||||
? `Page ${page}/${totalPages} of ${Utils.formatNumber(total)} voters \u2022 Use \u25C0\u25B6 to navigate`
|
||||
: `${Utils.formatNumber(total)} voter${total !== 1 ? "s" : ""} total`;
|
||||
? t(guildId, "responses.vote.pageInfo", { page, totalPages, total: Utils.formatNumber(total) })
|
||||
: t(guildId, "responses.vote.voterTotal", { total: Utils.formatNumber(total) });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
@@ -101,6 +101,8 @@ export async function run(msg, data) {
|
||||
const type = data.get("type")?.value ?? "bot";
|
||||
const resourceId = data.get("id")?.value || null;
|
||||
const page = data.get("page")?.value ?? 1;
|
||||
const t = this.locale?.translate?.bind(this.locale);
|
||||
const guildId = msg.message?.guildId;
|
||||
|
||||
switch (action) {
|
||||
case "info": {
|
||||
@@ -111,41 +113,30 @@ export async function run(msg, data) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setTitle("FluxerList Vote")
|
||||
.setDescription([
|
||||
`Vote for this bot/server on [FluxerList](${FLUXERLIST.SITE_URL})!`,
|
||||
``,
|
||||
`FluxerList is a server and bot listing platform where users can vote to help grow the community.`,
|
||||
``,
|
||||
`**Commands:**`,
|
||||
`\`${prefix}vote info\` \u2014 Show this info & vote link`,
|
||||
`\`${prefix}vote info server\` \u2014 Show vote link for a server`,
|
||||
`\`${prefix}vote check\` \u2014 Check who voted (owner-only)`,
|
||||
`\`${prefix}vote voters\` \u2014 View the voter list (owner-only)`,
|
||||
].join("\n"))]
|
||||
.setTitle(this.t(msg, "responses.vote.infoTitle"))
|
||||
.setDescription(this.t(msg, "responses.vote.infoDescription", { siteUrl: FLUXERLIST.SITE_URL, prefix }))]
|
||||
});
|
||||
}
|
||||
|
||||
const slug = resourceId || (resolvedType === "server" ? fluxerlist?.serverSlug : fluxerlist?.botSlug);
|
||||
const voteUrl = slug ? buildVoteLink(resolvedType, slug) : null;
|
||||
const label = resolvedType === "server" ? "Server" : "Bot";
|
||||
|
||||
const descLines = [
|
||||
`Support this ${label.toLowerCase()} by voting on FluxerList!`,
|
||||
this.t(msg, "responses.vote.supportDesc", { type: resolvedType }),
|
||||
``,
|
||||
];
|
||||
|
||||
if (voteUrl) {
|
||||
descLines.push(`**[Vote & View Profile](${voteUrl})**`, ``);
|
||||
descLines.push(this.t(msg, "responses.vote.voteLink", { url: voteUrl }), ``);
|
||||
} else {
|
||||
descLines.push(`Visit [FluxerList](${FLUXERLIST.SITE_URL}) to find and vote for this ${label.toLowerCase()}.`, ``);
|
||||
descLines.push(this.t(msg, "responses.vote.findLink", { siteUrl: FLUXERLIST.SITE_URL, type: resolvedType }), ``);
|
||||
}
|
||||
|
||||
descLines.push(`Your votes help this ${label.toLowerCase()} grow and reach more users.`);
|
||||
descLines.push(this.t(msg, "responses.vote.helpGrow", { type: resolvedType }));
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setTitle(`Vote on FluxerList`)
|
||||
.setTitle(this.t(msg, "responses.vote.voteTitle"))
|
||||
.setDescription(descLines.join("\n"));
|
||||
|
||||
return msg.reply({ embeds: [embed] });
|
||||
@@ -153,12 +144,12 @@ export async function run(msg, data) {
|
||||
|
||||
case "check":
|
||||
case "voters": {
|
||||
if (!fluxerlist || !fluxerlist.enabled) return msg.reply(notConfigured(prefix));
|
||||
if (!fluxerlist || !fluxerlist.enabled) return msg.reply(notConfigured(prefix, t, guildId));
|
||||
|
||||
const resolvedType = type || "bot";
|
||||
const id = resourceId || (resolvedType === "server" ? fluxerlist.serverId : fluxerlist.botId);
|
||||
|
||||
if (!id) return msg.reply(noResourceId(resolvedType, prefix));
|
||||
if (!id) return msg.reply(noResourceId(resolvedType, prefix, t, guildId));
|
||||
|
||||
let voterData;
|
||||
try {
|
||||
@@ -167,7 +158,7 @@ export async function run(msg, data) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setDescription(`Failed to fetch voters: ${err.message}`)]
|
||||
.setDescription(this.t(msg, "responses.vote.fetchVotersFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,21 +166,21 @@ export async function run(msg, data) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(`No one has voted for this ${resolvedType} yet. Share the vote link to get started!`)]
|
||||
.setDescription(this.t(msg, "responses.vote.noVotersYet", { type: resolvedType }))]
|
||||
});
|
||||
}
|
||||
|
||||
const totalPages = Math.max(1, Math.ceil(voterData.total / 20));
|
||||
|
||||
if (totalPages <= 1) {
|
||||
const embed = buildVotersEmbed(voterData.voters, voterData.total, voterData.page, 20, resolvedType, id);
|
||||
const embed = buildVotersEmbed(voterData.voters, voterData.total, voterData.page, 20, resolvedType, id, false, t, guildId);
|
||||
return msg.reply(embed);
|
||||
}
|
||||
|
||||
let currentPage = voterData.page;
|
||||
|
||||
const buildPage = (pageIdx, expired = false) => {
|
||||
return buildVotersEmbed(voterData.voters, voterData.total, pageIdx, 20, resolvedType, id, expired);
|
||||
return buildVotersEmbed(voterData.voters, voterData.total, pageIdx, 20, resolvedType, id, expired, t, guildId);
|
||||
};
|
||||
|
||||
const replyMsg = await msg.reply(buildPage(currentPage));
|
||||
@@ -254,16 +245,12 @@ export async function run(msg, data) {
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription([
|
||||
`**FluxerList Vote Commands:**`,
|
||||
this.t(msg, "responses.vote.defaultCommandsTitle"),
|
||||
``,
|
||||
`\`${prefix}vote\` \u2014 Show vote info & link`,
|
||||
`\`${prefix}vote info\` \u2014 Show voting info & vote link`,
|
||||
`\`${prefix}vote check\` \u2014 Check who voted (owner-only)`,
|
||||
`\`${prefix}vote voters\` \u2014 View the voter list (owner-only)`,
|
||||
this.t(msg, "responses.vote.defaultCommandsList", { prefix }),
|
||||
``,
|
||||
`**Options:**`,
|
||||
`\`${prefix}vote check server\` \u2014 Check voters for a server`,
|
||||
`\`${prefix}vote check bot\` \u2014 Check voters for a bot`,
|
||||
this.t(msg, "responses.vote.optionsTitle"),
|
||||
this.t(msg, "responses.vote.optionsList", { prefix }),
|
||||
].join("\n"))]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user