Files
fluxer/commands/forceleave.mjs
T
NoLogicAlan 85f11fe34b fix: migrate all commands & src to @fluxerjs native API
- Replace replyEmbed/sendEmbed/editEmbed with reply/send/edit
  across all 33 command files and 5 src/ files
- Remove unnecessary .toJSON() on EmbedBuilder (Fluxer auto-converts)
- Fix voice channel type checks: channel_type === "VoiceChannel" → type === 2
- Add missing edit() and send() methods to Message/ChannelContext wrappers
- Fix filter command: reactions now update per page on navigation

Closes channel cache crash (guild.channels.cache.keys undefined)
2026-05-05 20:09:25 +03:00

37 lines
1.4 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("❌ Channel not found."));
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."));
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."));
await this.players.leave(msg, cid);
}