mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
- 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
37 lines
1.5 KiB
JavaScript
37 lines
1.5 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("forceleave")
|
|
.addAlias("fl")
|
|
.setDescription("Make Remix leave a channel even if you're not in it.")
|
|
.setRequirement(r => r.addPermission("ManageChannels"))
|
|
.setCategory("music")
|
|
.addChannelOption(o =>
|
|
o.setName("channelId")
|
|
.setDescription("The channel that should be left.")
|
|
.setRequired(true)
|
|
);
|
|
|
|
function embed(desc) {
|
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
|
}
|
|
|
|
function cleanId(value) {
|
|
return String(value ?? "").replace(/\D/g, "");
|
|
}
|
|
|
|
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(this.t(msg, "responses.forceleave.channelNotFound")));
|
|
if (cleanId(msg.message.guildId) !== cleanId(targetChannel.guildId))
|
|
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(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);
|
|
}
|