mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
- Add complete translations for en, ar-SA, ckb, tr, de-DE, and pt-BR - Localize author headers, fields, and footers for playnext, remove, move, and trackopt - Localize audio mastering fields for normalize and volumedefault - Localize Last.fm whoknows leaderboards and Crown Holder cards - Localize help command inspector and voice channel picker embeds - Ensure 0 missing keys and 100% translation coverage
59 lines
2.3 KiB
JavaScript
59 lines
2.3 KiB
JavaScript
/**
|
|
* @module commands/forceleave
|
|
* @description Force the bot to leave a voice channel (requires ManageChannels permission).
|
|
*/
|
|
|
|
import { CommandBuilder } from "../src/commands/index.mjs";
|
|
import { EmbedBuilder } from "@fluxerjs/core";
|
|
import { cleanId, getGlobalColor } from "../src/ui/index.mjs";
|
|
import { resolveChannelCached } from "../src/utils/Helpers247.mjs";
|
|
|
|
/**
|
|
* @type {CommandBuilder}
|
|
* @description Command definition for the forceleave command.
|
|
*/
|
|
export const command = new CommandBuilder()
|
|
.setName("forceleave")
|
|
.addAliases("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)
|
|
);
|
|
|
|
|
|
/**
|
|
* Run handler for the forceleave command.
|
|
* Validates the target channel and forces the bot to leave.
|
|
*
|
|
* @param {object} msg - The command message wrapper.
|
|
* @param {object} data - Parsed command data containing the channelId option.
|
|
* @returns {Promise<void>}
|
|
*/
|
|
export async function run(msg, data) {
|
|
const cid = cleanId(data.get("channelId").value);
|
|
const targetChannel = await resolveChannelCached(this.client, cid);
|
|
if (!targetChannel) {
|
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.forceleave.channelNotFound"));
|
|
return msg.reply({ embeds: [embed] });
|
|
}
|
|
if (cleanId(msg.message?.guildId) !== cleanId(targetChannel.guildId)) {
|
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.forceleave.wrongServer"));
|
|
return msg.reply({ embeds: [embed] });
|
|
}
|
|
const p = this.players.playerMap.get(cid)
|
|
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
|
|
if (!p) {
|
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.forceleave.playerNotFound"));
|
|
return msg.reply({ embeds: [embed] });
|
|
}
|
|
if (!p.connection) {
|
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.forceleave.playerNotInit"));
|
|
return msg.reply({ embeds: [embed] });
|
|
}
|
|
await this.players.leave(msg, cid);
|
|
}
|