mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
cleaning
This commit is contained in:
1 parent
a557c37d08
commit
b2e7f062e9
1 file changed
+26
-11
+26
-11
@@ -14,17 +14,29 @@ function embed(desc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function run(msg) {
|
export async function run(msg) {
|
||||||
const guildId = msg.channel?.guild?.id ?? msg.message?.guildId;
|
const guildId = msg.channel?.guild?.id
|
||||||
|
?? msg.channel?.guildId
|
||||||
|
?? msg.channel?.server_id
|
||||||
|
?? msg.channel?.serverId
|
||||||
|
?? msg.message?.guildId
|
||||||
|
?? msg.message?.server_id
|
||||||
|
?? msg.message?.serverId;
|
||||||
|
|
||||||
const userChannelId = this.players.checkVoiceChannels(msg);
|
const userChannelId = this.players.checkVoiceChannels(msg);
|
||||||
if (!userChannelId) return msg.replyEmbed(embed("⚠️ Please join a voice channel first."));
|
if (!userChannelId) return msg.replyEmbed(embed("⚠️ Please join a voice channel first."));
|
||||||
|
|
||||||
const cid = String(userChannelId).replace(/\D/g, "");
|
const cid = String(userChannelId).replace(/\D/g, "");
|
||||||
|
const cleanGuildId = String(guildId ?? "").replace(/\D/g, "");
|
||||||
|
|
||||||
if (!this.players.playerMap.has(cid)) {
|
const player = this.players.playerMap.get(cid)
|
||||||
|
?? [...this.players.playerMap.values()].find(p =>
|
||||||
|
String(p?._channelId ?? "").replace(/\D/g, "") === cid
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!player) {
|
||||||
const guildChannels = [...this.players.playerMap.entries()]
|
const guildChannels = [...this.players.playerMap.entries()]
|
||||||
.filter(([chId, p]) => p._guildId === guildId)
|
.filter(([, p]) => String(p?._guildId ?? "").replace(/\D/g, "") === cleanGuildId)
|
||||||
.map(([chId]) => `<#${chId}>`);
|
.map(([chId, p]) => `<#${String(p?._channelId ?? chId).replace(/\D/g, "")}>`);
|
||||||
|
|
||||||
if (guildChannels.length === 0) return msg.replyEmbed(embed("I'm not in a voice channel."));
|
if (guildChannels.length === 0) return msg.replyEmbed(embed("I'm not in a voice channel."));
|
||||||
if (guildChannels.length === 1) return msg.replyEmbed(embed(`⚠️ Please join ${guildChannels[0]} to use this command.`));
|
if (guildChannels.length === 1) return msg.replyEmbed(embed(`⚠️ Please join ${guildChannels[0]} to use this command.`));
|
||||||
@@ -34,8 +46,9 @@ export async function run(msg) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = this.players.playerMap.get(cid);
|
|
||||||
if (!player?.connection) return msg.replyEmbed(embed("Player not initialized."));
|
if (!player?.connection) return msg.replyEmbed(embed("Player not initialized."));
|
||||||
|
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||||
|
const homeChannelId = String(player._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
||||||
|
|
||||||
const set = this.getSettings(msg);
|
const set = this.getSettings(msg);
|
||||||
const raw = set?.get("stay_247");
|
const raw = set?.get("stay_247");
|
||||||
@@ -45,10 +58,12 @@ export async function run(msg) {
|
|||||||
? new Set(raw.map(id => String(id).replace(/\D/g, "")).filter(Boolean))
|
? new Set(raw.map(id => String(id).replace(/\D/g, "")).filter(Boolean))
|
||||||
: new Set([String(raw).replace(/\D/g, "")]);
|
: new Set([String(raw).replace(/\D/g, "")]);
|
||||||
|
|
||||||
if (ch247.has(cid)) {
|
if (ch247.has(activeChannelId) || ch247.has(homeChannelId)) {
|
||||||
const mode = set?.get("stay_247_mode") ?? "auto";
|
const mode = set?.get("stay_247_mode") ?? "auto";
|
||||||
this.markIntentionalLeave(cid);
|
this.markIntentionalLeave(activeChannelId);
|
||||||
this.players.playerMap.delete(cid);
|
this.players.playerMap.delete(activeChannelId);
|
||||||
|
if (activeChannelId !== cid) this.players.playerMap.delete(cid);
|
||||||
|
if (homeChannelId !== activeChannelId) this.players.playerMap.delete(homeChannelId);
|
||||||
await player.leave().catch(() => {});
|
await player.leave().catch(() => {});
|
||||||
player.destroy();
|
player.destroy();
|
||||||
|
|
||||||
@@ -57,8 +72,8 @@ export async function run(msg) {
|
|||||||
const leave247Delay = this.config?.timers?.leave247RejoinDelay ?? 5000;
|
const leave247Delay = this.config?.timers?.leave247RejoinDelay ?? 5000;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this._spawnPlayer) {
|
if (this._spawnPlayer) {
|
||||||
this._spawnPlayer(guildId, cid).catch(e =>
|
this._spawnPlayer(guildId, homeChannelId).catch(e =>
|
||||||
logger.warn("[leave] 247 rejoin failed for", cid, e.message)
|
logger.warn("[leave] 247 rejoin failed for", homeChannelId, e.message)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, leave247Delay);
|
}, leave247Delay);
|
||||||
@@ -66,6 +81,6 @@ export async function run(msg) {
|
|||||||
msg.replyEmbed(embed(`✅ Successfully Left.\nℹ️ 24/7 mode is **on** — bot won't rejoin automatically. Use \`%play\` to bring it back, or \`%247 off\` to fully disable.`));
|
msg.replyEmbed(embed(`✅ Successfully Left.\nℹ️ 24/7 mode is **on** — bot won't rejoin automatically. Use \`%play\` to bring it back, or \`%247 off\` to fully disable.`));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await this.leaveChannel(cid, guildId, msg);
|
await this.leaveChannel(activeChannelId, guildId, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user