Files
fluxer/commands/skip.mjs
T
NoLogicAlan 6060e6d318 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
2026-05-06 01:07:03 +03:00

35 lines
1.1 KiB
JavaScript

import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
export const command = new CommandBuilder()
.setName("skip")
.setDescription("Skip the current playing song.", "commands.skip")
.addAliases("s")
.setCategory("music");
export async function run(message) {
const p = await this.getPlayer(message);
if (!p) return;
const current = p.queue.getCurrent();
const skippedTitle = current?.title ?? null;
const skippedLink = current ? (current.spotifyUrl || current.url || "") : "";
const err = p.skip();
if (err && err.includes("nothing playing")) {
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(err);
return message.reply({ embeds: [embed] });
}
const desc = skippedTitle
? this.t(message, "responses.skip.skippedTrack", { title: skippedTitle, url: skippedLink })
: this.t(message, "responses.skip.skipped");
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription(desc)
;
message.reply({ embeds: [embed] });
}