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
06bcc93ced
commit
3d66043864
5 files changed
+37
-23
No files matched your search
+7
-3
@@ -39,6 +39,8 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
});
|
||||
|
||||
p.on("autoleave", () => {
|
||||
const activeChannelId = String(p._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||
const homeChannelId = String(p._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
||||
const guildId = message.channel?.guildId
|
||||
?? message.channel?.guild?.id
|
||||
?? message.message?.guildId
|
||||
@@ -56,13 +58,15 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
} catch (_) { return "%"; }
|
||||
})();
|
||||
const desc = is247
|
||||
? `Left channel <#${cid}> because of inactivity.`
|
||||
: `Left channel <#${cid}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
||||
? `Left channel <#${activeChannelId}> because of inactivity.`
|
||||
: `Left channel <#${activeChannelId}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||
.setDescription(desc)
|
||||
.toJSON();
|
||||
message.channel.sendEmbed({ embeds: [embed] });
|
||||
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);
|
||||
p.destroy();
|
||||
});
|
||||
|
||||
|
||||
+13
-6
@@ -123,9 +123,15 @@ async function handle247(ctx, message, value) {
|
||||
channels.delete(id);
|
||||
save247Channels(set, channels);
|
||||
ctx.markIntentionalLeave?.(id);
|
||||
const player = ctx.players.playerMap.get(id);
|
||||
const player = ctx.players.playerMap.get(id)
|
||||
?? [...ctx.players.playerMap.values()].find(p =>
|
||||
cleanId(p?._channelId ?? "") === id &&
|
||||
cleanId(p?._guildId ?? "") === cleanId(guildId)
|
||||
);
|
||||
if (player) {
|
||||
ctx.players.playerMap.delete(id);
|
||||
const activeChannelId = cleanId(player._channelId ?? id);
|
||||
ctx.players.playerMap.delete(activeChannelId);
|
||||
if (activeChannelId !== id) ctx.players.playerMap.delete(id);
|
||||
await player.leave().catch(() => {});
|
||||
player.destroy();
|
||||
}
|
||||
@@ -137,10 +143,11 @@ async function handle247(ctx, message, value) {
|
||||
save247Channels(set, new Set());
|
||||
set.set("stay_247_mode", "off");
|
||||
for (const [chId, player] of [...ctx.players.playerMap.entries()]) {
|
||||
const ch = ctx.handler.client.channels.cache.get(chId);
|
||||
if (ch?.guild?.id === guildId || ch?.guildId === guildId) {
|
||||
ctx.markIntentionalLeave?.(chId);
|
||||
ctx.players.playerMap.delete(chId);
|
||||
if (cleanId(player?._guildId ?? "") === cleanId(guildId)) {
|
||||
const activeChannelId = cleanId(player._channelId ?? chId);
|
||||
ctx.markIntentionalLeave?.(activeChannelId);
|
||||
ctx.players.playerMap.delete(activeChannelId);
|
||||
if (activeChannelId !== chId) ctx.players.playerMap.delete(chId);
|
||||
await player.leave().catch(() => {});
|
||||
player.destroy();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user