mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
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)
This commit is contained in:
1 parent
19820e7209
commit
85f11fe34b
38 files changed
+381
-300
No files matched your search
+2
-2
@@ -15,6 +15,6 @@ export async function run(msg) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription("🗑️ Queue cleared.")
|
.setDescription("🗑️ Queue cleared.")
|
||||||
.toJSON();
|
;
|
||||||
msg.replyEmbed({ embeds: [embed] });
|
msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+3
-3
@@ -17,7 +17,7 @@ export function run(msg, data) {
|
|||||||
switch (data.get("target").value) {
|
switch (data.get("target").value) {
|
||||||
case "voice": {
|
case "voice": {
|
||||||
const servers = [...this.players.playerMap.entries()].map(([cid, s]) => {
|
const servers = [...this.players.playerMap.entries()].map(([cid, s]) => {
|
||||||
const channel = this.client.channels.cache.get(cid);
|
const channel = this.client.channels.get(cid);
|
||||||
return {
|
return {
|
||||||
name: channel?.name ?? "unknown",
|
name: channel?.name ?? "unknown",
|
||||||
id: channel?.id ?? cid,
|
id: channel?.id ?? cid,
|
||||||
@@ -30,8 +30,8 @@ export function run(msg, data) {
|
|||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setTitle("🔧 Voice Debug")
|
.setTitle("🔧 Voice Debug")
|
||||||
.setDescription("```json\n" + JSON.stringify(servers, null, 2) + "\n```")
|
.setDescription("```json\n" + JSON.stringify(servers, null, 2) + "\n```")
|
||||||
.toJSON();
|
;
|
||||||
msg.replyEmbed({ embeds: [embed] });
|
msg.reply({ embeds: [embed] });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -162,13 +162,13 @@ export async function run(msg, data) {
|
|||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setDescription(desc)
|
.setDescription(desc)
|
||||||
.setFooter({ text: footerText })
|
.setFooter({ text: footerText })
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
return { embeds: [embed] };
|
return { embeds: [embed] };
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3. Send the initial message using the wrapper
|
// 3. Send the initial message using the wrapper
|
||||||
const replyMsg = await msg.replyEmbed(buildPageContent(0));
|
const replyMsg = await msg.reply(buildPageContent(0));
|
||||||
if (!replyMsg?.message) return;
|
if (!replyMsg?.message) return;
|
||||||
|
|
||||||
// 4. Setup React UI
|
// 4. Setup React UI
|
||||||
@@ -200,7 +200,7 @@ export async function run(msg, data) {
|
|||||||
emojiTimeout = setTimeout(async () => {
|
emojiTimeout = setTimeout(async () => {
|
||||||
if (unobserve) unobserve();
|
if (unobserve) unobserve();
|
||||||
await clearReactions();
|
await clearReactions();
|
||||||
await replyMsg.editEmbed(buildPageContent(currentPage, true)).catch(() => {});
|
await replyMsg.edit(buildPageContent(currentPage, true)).catch(() => {});
|
||||||
}, EMOJI_REMOVE_TIMEOUT);
|
}, EMOJI_REMOVE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ export async function run(msg, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update Embed
|
// Update Embed
|
||||||
await replyMsg.editEmbed(buildPageContent(currentPage)).catch(() => {});
|
await replyMsg.edit(buildPageContent(currentPage)).catch(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
resetTimer();
|
resetTimer();
|
||||||
|
|||||||
+33
-16
@@ -240,7 +240,7 @@ function buildPageEmbed(page, activeKeys, current) {
|
|||||||
.setFooter({
|
.setFooter({
|
||||||
text: `Page ${page + 1}/${totalPages} • React with a filter emoji to toggle it`
|
text: `Page ${page + 1}/${totalPages} • React with a filter emoji to toggle it`
|
||||||
})
|
})
|
||||||
.toJSON();
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Command handler ───────────────────────────────────────────────────────────
|
// ── Command handler ───────────────────────────────────────────────────────────
|
||||||
@@ -264,7 +264,7 @@ export async function run(msg) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const current = player.queue.getCurrent();
|
const current = player.queue.getCurrent();
|
||||||
const menuMsg = await msg.replyEmbed({
|
const menuMsg = await msg.reply({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, current)]
|
embeds: [buildPageEmbed(page, activeKeys, current)]
|
||||||
});
|
});
|
||||||
if (!menuMsg?.message) return;
|
if (!menuMsg?.message) return;
|
||||||
@@ -278,6 +278,13 @@ export async function run(msg) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removePageFilterEmojis = async (p) => {
|
||||||
|
const pageEmojis = getPageItems(p).map(f => f.emoji);
|
||||||
|
for (const emoji of pageEmojis) {
|
||||||
|
try { await menuMsg.message.removeReaction(emoji); } catch (_) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
await addReactions(page);
|
await addReactions(page);
|
||||||
|
|
||||||
let settled = false;
|
let settled = false;
|
||||||
@@ -313,9 +320,9 @@ export async function run(msg) {
|
|||||||
: `🔇 No filter active.\n\n${reason}`
|
: `🔇 No filter active.\n\n${reason}`
|
||||||
)
|
)
|
||||||
.setFooter({ text: "Session ended" })
|
.setFooter({ text: "Session ended" })
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
await menuMsg.editEmbed({ embeds: [closedEmbed] }).catch(() => {});
|
await menuMsg.edit({ embeds: [closedEmbed] }).catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetTimer = () => {
|
const resetTimer = () => {
|
||||||
@@ -342,16 +349,26 @@ export async function run(msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (emoji === PREV_EMOJI) {
|
if (emoji === PREV_EMOJI) {
|
||||||
|
const prevPage = page;
|
||||||
page = (page - 1 + totalPages) % totalPages;
|
page = (page - 1 + totalPages) % totalPages;
|
||||||
await menuMsg.editEmbed({
|
if (page !== prevPage) {
|
||||||
|
await removePageFilterEmojis(prevPage);
|
||||||
|
await addReactions(page);
|
||||||
|
}
|
||||||
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
|
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emoji === NEXT_EMOJI) {
|
if (emoji === NEXT_EMOJI) {
|
||||||
|
const prevPage = page;
|
||||||
page = (page + 1) % totalPages;
|
page = (page + 1) % totalPages;
|
||||||
await menuMsg.editEmbed({
|
if (page !== prevPage) {
|
||||||
|
await removePageFilterEmojis(prevPage);
|
||||||
|
await addReactions(page);
|
||||||
|
}
|
||||||
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
|
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
return;
|
return;
|
||||||
@@ -364,16 +381,16 @@ export async function run(msg) {
|
|||||||
const track = player.queue.getCurrent();
|
const track = player.queue.getCurrent();
|
||||||
const previousActiveKeys = [...activeKeys];
|
const previousActiveKeys = [...activeKeys];
|
||||||
if (!track && false) { // pending filters are allowed; keep old fallback block unreachable
|
if (!track && false) { // pending filters are allowed; keep old fallback block unreachable
|
||||||
await menuMsg.editEmbed({
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, null)]
|
embeds: [buildPageEmbed(page, activeKeys, null)]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
const errEmbed = new EmbedBuilder()
|
const errEmbed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription("❌ Nothing is playing right now.")
|
.setDescription("❌ Nothing is playing right now.")
|
||||||
.toJSON();
|
;
|
||||||
await menuMsg.editEmbed({ embeds: [errEmbed] }).catch(() => {});
|
await menuMsg.edit({ embeds: [errEmbed] }).catch(() => {});
|
||||||
await Utils.sleep(2000);
|
await Utils.sleep(2000);
|
||||||
await menuMsg.editEmbed({
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, null)]
|
embeds: [buildPageEmbed(page, activeKeys, null)]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
return;
|
return;
|
||||||
@@ -412,10 +429,10 @@ export async function run(msg) {
|
|||||||
`❌ Failed to apply **${filter.label}**: \`${reason}\`\n\n` +
|
`❌ Failed to apply **${filter.label}**: \`${reason}\`\n\n` +
|
||||||
`Make sure your NodeLink node has filters enabled.`
|
`Make sure your NodeLink node has filters enabled.`
|
||||||
)
|
)
|
||||||
.toJSON();
|
;
|
||||||
await menuMsg.editEmbed({ embeds: [errEmbed] }).catch(() => {});
|
await menuMsg.edit({ embeds: [errEmbed] }).catch(() => {});
|
||||||
await Utils.sleep(3000);
|
await Utils.sleep(3000);
|
||||||
await menuMsg.editEmbed({
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, track)]
|
embeds: [buildPageEmbed(page, activeKeys, track)]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
return;
|
return;
|
||||||
@@ -443,14 +460,14 @@ export async function run(msg) {
|
|||||||
`*${filter.desc}*\n\n` +
|
`*${filter.desc}*\n\n` +
|
||||||
`💡 React again to toggle, or ${CANCEL_EMOJI} to close.`
|
`💡 React again to toggle, or ${CANCEL_EMOJI} to close.`
|
||||||
)
|
)
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
await menuMsg.editEmbed({ embeds: [confirmEmbed] }).catch(() => {});
|
await menuMsg.edit({ embeds: [confirmEmbed] }).catch(() => {});
|
||||||
await Utils.sleep(2500);
|
await Utils.sleep(2500);
|
||||||
|
|
||||||
// Restore picker (session stays open)
|
// Restore picker (session stays open)
|
||||||
if (!settled) {
|
if (!settled) {
|
||||||
await menuMsg.editEmbed({
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
|
embeds: [buildPageEmbed(page, activeKeys, player.queue.getCurrent())]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const command = new CommandBuilder()
|
|||||||
);
|
);
|
||||||
|
|
||||||
function embed(desc) {
|
function embed(desc) {
|
||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).toJSON()] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanId(value) {
|
function cleanId(value) {
|
||||||
@@ -24,13 +24,13 @@ function cleanId(value) {
|
|||||||
|
|
||||||
export async function run(msg, data) {
|
export async function run(msg, data) {
|
||||||
const cid = cleanId(data.get("channelId").value);
|
const cid = cleanId(data.get("channelId").value);
|
||||||
const targetChannel = this.client.channels.cache.get(cid);
|
const targetChannel = this.client.channels.get(cid);
|
||||||
if (!targetChannel) return msg.replyEmbed(embed("❌ Channel not found."));
|
if (!targetChannel) return msg.reply(embed("❌ Channel not found."));
|
||||||
if (cleanId(msg.message.guildId) !== cleanId(targetChannel.guildId))
|
if (cleanId(msg.message.guildId) !== cleanId(targetChannel.guildId))
|
||||||
return msg.replyEmbed(embed("❌ This command has to be run in the same server as the voice channel."));
|
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)
|
const p = this.players.playerMap.get(cid)
|
||||||
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
|
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
|
||||||
if (!p) return msg.replyEmbed(embed("❌ Player not found."));
|
if (!p) return msg.reply(embed("❌ Player not found."));
|
||||||
if (!p.connection) return msg.replyEmbed(embed("❌ Player not initialized."));
|
if (!p.connection) return msg.reply(embed("❌ Player not initialized."));
|
||||||
await this.players.leave(msg, cid);
|
await this.players.leave(msg, cid);
|
||||||
}
|
}
|
||||||
+2
-2
@@ -24,9 +24,9 @@ export async function run(message) {
|
|||||||
iconURL: botIcon
|
iconURL: botIcon
|
||||||
})
|
})
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
await message.replyEmbed({
|
await message.reply({
|
||||||
embeds: [embed]
|
embeds: [embed]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+25
-33
@@ -18,12 +18,11 @@ function cleanId(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||||
if (!this.client.channels.cache.has(cid)) {
|
if (!this.client.channels.has(cid)) {
|
||||||
ecb();
|
ecb();
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription("Couldn't find the channel `" + cid + "`\nUse the help command to learn more about this. (`%help join`)")
|
.setDescription("Couldn't find the channel `" + cid + "`\nUse the help command to learn more about this. (`%help join`)");
|
||||||
.toJSON();
|
return message.reply({ embeds: [embed] });
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
const cleanChannelId = cleanId(cid);
|
const cleanChannelId = cleanId(cid);
|
||||||
const existing = this.players.playerMap.get(cleanChannelId)
|
const existing = this.players.playerMap.get(cleanChannelId)
|
||||||
@@ -31,18 +30,16 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
|||||||
if (existing) {
|
if (existing) {
|
||||||
cb(existing);
|
cb(existing);
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription("Already joined <#" + cid + ">.")
|
.setDescription("Already joined <#" + cid + ">.");
|
||||||
.toJSON();
|
return message.reply({ embeds: [embed] });
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guard: moonlink must be ready before we can play anything
|
// Guard: moonlink must be ready before we can play anything
|
||||||
if (!this.moonlink) {
|
if (!this.moonlink) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription("⚠️ Audio node is still connecting — please try again in a few seconds.")
|
.setDescription("⚠️ Audio node is still connecting — please try again in a few seconds.");
|
||||||
.toJSON();
|
|
||||||
ecb();
|
ecb();
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
return message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const p = new Player(this.config.token, {
|
const p = new Player(this.config.token, {
|
||||||
@@ -74,9 +71,8 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
|||||||
? `Left channel <#${activeChannelId}> because of inactivity.`
|
? `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\``;
|
: `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())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription(desc)
|
.setDescription(desc);
|
||||||
.toJSON();
|
message.channel.send({ embeds: [embed] });
|
||||||
message.channel.sendEmbed({ embeds: [embed] });
|
|
||||||
this.players.playerMap.delete(activeChannelId);
|
this.players.playerMap.delete(activeChannelId);
|
||||||
if (activeChannelId !== cid) this.players.playerMap.delete(cid);
|
if (activeChannelId !== cid) this.players.playerMap.delete(cid);
|
||||||
if (homeChannelId !== activeChannelId) this.players.playerMap.delete(homeChannelId);
|
if (homeChannelId !== activeChannelId) this.players.playerMap.delete(homeChannelId);
|
||||||
@@ -89,24 +85,24 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
|||||||
const disabled = raw === false || raw === 0 ||
|
const disabled = raw === false || raw === 0 ||
|
||||||
["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim());
|
["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim());
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(m).toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(m);
|
||||||
message.channel.sendEmbed({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
});
|
});
|
||||||
|
|
||||||
this.players.playerMap.set(cleanChannelId, p);
|
this.players.playerMap.set(cleanChannelId, p);
|
||||||
|
|
||||||
const joiningEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("⏳ Joining Channel...").toJSON();
|
const joiningEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("⏳ Joining Channel...");
|
||||||
const statusMsg = await message.replyEmbed({ embeds: [joiningEmbed] });
|
const statusMsg = await message.reply({ embeds: [joiningEmbed] });
|
||||||
try {
|
try {
|
||||||
await p.join(cleanChannelId);
|
await p.join(cleanChannelId);
|
||||||
const okEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(`✅ Successfully joined <#${cid}>`).toJSON();
|
const okEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(`✅ Successfully joined <#${cid}>`);
|
||||||
await statusMsg.editEmbed({ embeds: [okEmbed] });
|
await statusMsg.edit({ embeds: [okEmbed] });
|
||||||
cb(p);
|
cb(p);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.players.playerMap.delete(cleanChannelId);
|
this.players.playerMap.delete(cleanChannelId);
|
||||||
p.destroy();
|
p.destroy();
|
||||||
const errEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(`❌ Failed to join: ${e.message}`).toJSON();
|
const errEmbed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(`❌ Failed to join: ${e.message}`);
|
||||||
await statusMsg.editEmbed({ embeds: [errEmbed] });
|
await statusMsg.edit({ embeds: [errEmbed] });
|
||||||
ecb(e);
|
ecb(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,25 +136,22 @@ export function run(message, data) {
|
|||||||
// Try to look up by name
|
// Try to look up by name
|
||||||
const guildId = cleanId(getGuildId(message));
|
const guildId = cleanId(getGuildId(message));
|
||||||
const allChannels = [
|
const allChannels = [
|
||||||
...(this._commands?.client?.channels?.values?.() ??
|
...(this.client?.channels?.values?.() ?? [])
|
||||||
this._commands?.client?.channels?.cache?.values?.() ??
|
|
||||||
this.client?.channels?.values?.() ??
|
|
||||||
this.client?.channels?.cache?.values?.() ?? [])
|
|
||||||
];
|
];
|
||||||
const match = allChannels.find(c => {
|
const match = allChannels.find(c => {
|
||||||
const cServerId = cleanId(c.guildId ?? c.guild?.id ?? c.server_id ?? c.serverId);
|
const cServerId = cleanId(c.guildId ?? c.guild?.id ?? c.server_id ?? c.serverId);
|
||||||
const isVoice = c.channel_type === "VoiceChannel" || c.type === "VoiceChannel" || c.type === 2;
|
// Fluxer uses numeric channel types: 0=text, 2=voice, 4=category, 5=link
|
||||||
|
const isVoice = c.type === 2;
|
||||||
return isVoice && cServerId === guildId &&
|
return isVoice && cServerId === guildId &&
|
||||||
(c.name?.toLowerCase() === rawArg.toLowerCase());
|
(c.name?.toLowerCase() === rawArg.toLowerCase());
|
||||||
});
|
});
|
||||||
if (match) resolvedId = match._id ?? match.id;
|
if (match) resolvedId = match.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resolvedId) {
|
if (!resolvedId) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription("❌ Couldn't find that voice channel. Try using a mention like `<#channelid>` or the exact channel name.")
|
.setDescription("❌ Couldn't find that voice channel. Try using a mention like `<#channelid>` or the exact channel name.");
|
||||||
.toJSON();
|
return message.reply({ embeds: [embed] });
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.players.initPlayer(message, resolvedId);
|
return this.players.initPlayer(message, resolvedId);
|
||||||
@@ -170,9 +163,8 @@ export function run(message, data) {
|
|||||||
if (!cid) {
|
if (!cid) {
|
||||||
const prefix = this._commands?.getPrefix?.(getGuildId(message)) ?? "%";
|
const prefix = this._commands?.getPrefix?.(getGuildId(message)) ?? "%";
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription(`❌ You're not in a voice channel. Please join one first, or specify a channel: \`${prefix}join <#channel>\``)
|
.setDescription(`❌ You're not in a voice channel. Please join one first, or specify a channel: \`${prefix}join <#channel>\``);
|
||||||
.toJSON();
|
return message.reply({ embeds: [embed] });
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.players.initPlayer(message, cid);
|
this.players.initPlayer(message, cid);
|
||||||
|
|||||||
+8
-8
@@ -10,7 +10,7 @@ export const command = new CommandBuilder()
|
|||||||
.setCategory("music");
|
.setCategory("music");
|
||||||
|
|
||||||
function embed(desc) {
|
function embed(desc) {
|
||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).toJSON()] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function run(msg) {
|
export async function run(msg) {
|
||||||
@@ -23,7 +23,7 @@ export async function run(msg) {
|
|||||||
?? msg.message?.serverId;
|
?? 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.reply(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, "");
|
const cleanGuildId = String(guildId ?? "").replace(/\D/g, "");
|
||||||
@@ -44,15 +44,15 @@ export async function run(msg) {
|
|||||||
return liveId ? `<#${liveId}>` : "`unknown voice channel`";
|
return liveId ? `<#${liveId}>` : "`unknown voice channel`";
|
||||||
});
|
});
|
||||||
|
|
||||||
if (guildChannels.length === 0) return msg.replyEmbed(embed("I'm not in a voice channel."));
|
if (guildChannels.length === 0) return msg.reply(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.reply(embed(`⚠️ Please join ${guildChannels[0]} to use this command.`));
|
||||||
return msg.replyEmbed(embed(
|
return msg.reply(embed(
|
||||||
`⚠️ I'm playing in multiple channels! Please join one of them:\n` +
|
`⚠️ I'm playing in multiple channels! Please join one of them:\n` +
|
||||||
guildChannels.map(c => `• ${c}`).join("\n")
|
guildChannels.map(c => `• ${c}`).join("\n")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player?.connection) return msg.replyEmbed(embed("Player not initialized."));
|
if (!player?.connection) return msg.reply(embed("Player not initialized."));
|
||||||
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
|
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||||
const homeChannelId = String(player._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
const homeChannelId = String(player._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ export async function run(msg) {
|
|||||||
player.destroy();
|
player.destroy();
|
||||||
|
|
||||||
if (mode === "auto") {
|
if (mode === "auto") {
|
||||||
msg.replyEmbed(embed(`✅ Successfully Left — rejoining <#${cid}> in 5 seconds.\nTo disable 24/7 mode permanently, use \`%247 off\`.`));
|
msg.reply(embed(`✅ Successfully Left — rejoining <#${cid}> in 5 seconds.\nTo disable 24/7 mode permanently, use \`%247 off\`.`));
|
||||||
const leave247Delay = this.config?.timers?.leave247RejoinDelay ?? 5000;
|
const leave247Delay = this.config?.timers?.leave247RejoinDelay ?? 5000;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this._spawnPlayer) {
|
if (this._spawnPlayer) {
|
||||||
@@ -84,7 +84,7 @@ export async function run(msg) {
|
|||||||
}
|
}
|
||||||
}, leave247Delay);
|
}, leave247Delay);
|
||||||
} else {
|
} else {
|
||||||
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.reply(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(activeChannelId, guildId, msg);
|
await this.leaveChannel(activeChannelId, guildId, msg);
|
||||||
|
|||||||
+3
-3
@@ -24,8 +24,8 @@ export async function run(message, data) {
|
|||||||
const totalTracks = p.queue.size();
|
const totalTracks = p.queue.size();
|
||||||
|
|
||||||
if (!current && totalTracks === 0) {
|
if (!current && totalTracks === 0) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("📭 The queue is empty. Use `%play` to add songs!").toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("📭 The queue is empty. Use `%play` to add songs!");
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
return message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalPages = totalTracks > 0
|
const totalPages = totalTracks > 0
|
||||||
@@ -85,7 +85,7 @@ export async function run(message, data) {
|
|||||||
.setAuthor({ name: "🎧 Queue" })
|
.setAuthor({ name: "🎧 Queue" })
|
||||||
.setDescription(desc.trim())
|
.setDescription(desc.trim())
|
||||||
.setFooter({ text: `Page ${safePage}/${totalPages} • ${loopState}` })
|
.setFooter({ text: `Page ${safePage}/${totalPages} • ${loopState}` })
|
||||||
.toJSON();
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
new QueuePaginator(message, this.messages, this.client)
|
new QueuePaginator(message, this.messages, this.client)
|
||||||
|
|||||||
+4
-4
@@ -15,8 +15,8 @@ export async function run(msg, data) {
|
|||||||
const code = data.get("id").value;
|
const code = data.get("id").value;
|
||||||
|
|
||||||
if (!this.dashboard?.enabled) {
|
if (!this.dashboard?.enabled) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ The dashboard is not enabled on this bot.").toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ The dashboard is not enabled on this bot.");
|
||||||
return msg.replyEmbed({ embeds: [embed] });
|
return msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const error = await this.dashboard.confirmLogin(msg.author.id, code);
|
const error = await this.dashboard.confirmLogin(msg.author.id, code);
|
||||||
@@ -24,6 +24,6 @@ export async function run(msg, data) {
|
|||||||
? "✅ Login succeeded! You can continue to the webpage now."
|
? "✅ Login succeeded! You can continue to the webpage now."
|
||||||
: "❌ Login failed! Reason: `" + error + "`. If this is an error and the issue persists, please contact a team member through the server in my description.";
|
: "❌ Login failed! Reason: `" + error + "`. If this is an error and the issue persists, please contact a team member through the server in my description.";
|
||||||
|
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
||||||
msg.replyEmbed({ embeds: [embed] });
|
msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+2
-2
@@ -19,6 +19,6 @@ export async function run(message, data) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription(res)
|
.setDescription(res)
|
||||||
.toJSON();
|
;
|
||||||
message.replyEmbed({ embeds: [embed] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+15
-15
@@ -20,24 +20,24 @@ export async function run(message) {
|
|||||||
|
|
||||||
const current = p.queue.getCurrent();
|
const current = p.queue.getCurrent();
|
||||||
if (!current) {
|
if (!current) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ There's nothing playing at the moment.").toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ There's nothing playing at the moment.");
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
return message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animated loading spinner
|
// Animated loading spinner
|
||||||
let frame = 0;
|
let frame = 0;
|
||||||
const loadingMsg = await message.replyEmbed({ embeds: [
|
const loadingMsg = await message.reply({ embeds: [
|
||||||
new EmbedBuilder().setColor(getGlobalColor())
|
new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription(`${LOADING_FRAMES[0]} Searching lyrics for **${Utils.truncate(current.title, 40)}**...`)
|
.setDescription(`${LOADING_FRAMES[0]} Searching lyrics for **${Utils.truncate(current.title, 40)}**...`)
|
||||||
.toJSON()
|
|
||||||
] });
|
] });
|
||||||
|
|
||||||
const loadingInterval = setInterval(() => {
|
const loadingInterval = setInterval(() => {
|
||||||
frame = (frame + 1) % LOADING_FRAMES.length;
|
frame = (frame + 1) % LOADING_FRAMES.length;
|
||||||
loadingMsg.editEmbed({ embeds: [
|
loadingMsg.edit({ embeds: [
|
||||||
new EmbedBuilder().setColor(getGlobalColor())
|
new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription(`${LOADING_FRAMES[frame]} Searching lyrics for **${Utils.truncate(current.title, 40)}**...`)
|
.setDescription(`${LOADING_FRAMES[frame]} Searching lyrics for **${Utils.truncate(current.title, 40)}**...`)
|
||||||
.toJSON()
|
|
||||||
] }).catch(() => {});
|
] }).catch(() => {});
|
||||||
}, 800);
|
}, 800);
|
||||||
|
|
||||||
@@ -47,12 +47,12 @@ export async function run(message) {
|
|||||||
clearInterval(loadingInterval);
|
clearInterval(loadingInterval);
|
||||||
|
|
||||||
if (!result || !result.text) {
|
if (!result || !result.text) {
|
||||||
return loadingMsg.editEmbed({ embeds: [
|
return loadingMsg.edit({ embeds: [
|
||||||
new EmbedBuilder().setColor(getGlobalColor())
|
new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`❌ No lyrics available for **${Utils.truncate(current.title, 40)}**.\n\n` +
|
`❌ No lyrics available for **${Utils.truncate(current.title, 40)}**.\n\n` +
|
||||||
`💡 NodeLink lyrics plugin may not have this track. Try a popular song!`
|
`💡 NodeLink lyrics plugin may not have this track. Try a popular song!`
|
||||||
).toJSON()
|
)
|
||||||
] });
|
] });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ export async function run(message) {
|
|||||||
].join("\n"))
|
].join("\n"))
|
||||||
.setFooter({ text: `NodeLink • ${totalLines} lines` });
|
.setFooter({ text: `NodeLink • ${totalLines} lines` });
|
||||||
if (current.thumbnail) singleEmbed.setThumbnail(current.thumbnail);
|
if (current.thumbnail) singleEmbed.setThumbnail(current.thumbnail);
|
||||||
return message.replyEmbed({ embeds: [singleEmbed.toJSON()] });
|
return message.reply({ embeds: [singleEmbed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multi-page
|
// Multi-page
|
||||||
@@ -108,10 +108,10 @@ export async function run(message) {
|
|||||||
? `⌛ Controls expired • NodeLink • ${totalLines} lines`
|
? `⌛ Controls expired • NodeLink • ${totalLines} lines`
|
||||||
: `NodeLink • ${totalLines} lines total` });
|
: `NodeLink • ${totalLines} lines total` });
|
||||||
if (current.thumbnail) b.setThumbnail(current.thumbnail);
|
if (current.thumbnail) b.setThumbnail(current.thumbnail);
|
||||||
return { embeds: [b.toJSON()] };
|
return { embeds: [b] };
|
||||||
};
|
};
|
||||||
|
|
||||||
const msg = await message.replyEmbed(buildContent(0));
|
const msg = await message.reply(buildContent(0));
|
||||||
if (!msg?.message) return;
|
if (!msg?.message) return;
|
||||||
|
|
||||||
const emojis = ["⬅️", "➡️"];
|
const emojis = ["⬅️", "➡️"];
|
||||||
@@ -133,7 +133,7 @@ export async function run(message) {
|
|||||||
clearTimeout(emojiRemoveTimeout);
|
clearTimeout(emojiRemoveTimeout);
|
||||||
emojiRemoveTimeout = setTimeout(async () => {
|
emojiRemoveTimeout = setTimeout(async () => {
|
||||||
await clearReactions();
|
await clearReactions();
|
||||||
msg.editEmbed(buildContent(currentPage, true)).catch(() => {});
|
msg.edit(buildContent(currentPage, true)).catch(() => {});
|
||||||
}, EMOJI_REMOVE_TIMEOUT);
|
}, EMOJI_REMOVE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ export async function run(message) {
|
|||||||
} else if (e.emoji_id === "➡️") {
|
} else if (e.emoji_id === "➡️") {
|
||||||
currentPage = currentPage < totalPages - 1 ? currentPage + 1 : 0;
|
currentPage = currentPage < totalPages - 1 ? currentPage + 1 : 0;
|
||||||
}
|
}
|
||||||
msg.editEmbed(buildContent(currentPage)).catch(() => {});
|
msg.edit(buildContent(currentPage)).catch(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
resetEmojiTimer();
|
resetEmojiTimer();
|
||||||
@@ -165,12 +165,12 @@ export async function run(message) {
|
|||||||
].join("\n"))
|
].join("\n"))
|
||||||
.setFooter({ text: `Session closed • NodeLink • ${totalLines} lines` });
|
.setFooter({ text: `Session closed • NodeLink • ${totalLines} lines` });
|
||||||
if (current.thumbnail) closedEmbed.setThumbnail(current.thumbnail);
|
if (current.thumbnail) closedEmbed.setThumbnail(current.thumbnail);
|
||||||
msg.editEmbed({ embeds: [closedEmbed.toJSON()] }).catch(() => {});
|
msg.edit({ embeds: [closedEmbed] }).catch(() => {});
|
||||||
}, SESSION_MS);
|
}, SESSION_MS);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
clearInterval(loadingInterval);
|
clearInterval(loadingInterval);
|
||||||
logger.error("[Lyrics Command] Error:", err);
|
logger.error("[Lyrics Command] Error:", err);
|
||||||
loadingMsg.editEmbed({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`❌ Error: ${Utils.truncate(err.message, 100)}`).toJSON()] }).catch(() => {});
|
loadingMsg.edit({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(`❌ Error: ${Utils.truncate(err.message, 100)}`)] }).catch(() => {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -14,8 +14,8 @@ export async function run(msg) {
|
|||||||
const loadingEmbed = new EmbedBuilder()
|
const loadingEmbed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription("⏳ Loading...")
|
.setDescription("⏳ Loading...")
|
||||||
.toJSON();
|
;
|
||||||
const loadingMsg = await msg.replyEmbed({ embeds: [loadingEmbed] });
|
const loadingMsg = await msg.reply({ embeds: [loadingEmbed] });
|
||||||
|
|
||||||
const data = await p.nowPlaying();
|
const data = await p.nowPlaying();
|
||||||
|
|
||||||
@@ -24,5 +24,5 @@ export async function run(msg) {
|
|||||||
.setDescription(data.msg);
|
.setDescription(data.msg);
|
||||||
if (data.image) embed.setThumbnail(data.image);
|
if (data.image) embed.setThumbnail(data.image);
|
||||||
|
|
||||||
loadingMsg.editEmbed({ embeds: [embed.toJSON()] }).catch(() => {});
|
loadingMsg.edit({ embeds: [embed] }).catch(() => {});
|
||||||
}
|
}
|
||||||
+2
-2
@@ -14,6 +14,6 @@ export async function run(message) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription(res)
|
.setDescription(res)
|
||||||
.toJSON();
|
;
|
||||||
message.replyEmbed({ embeds: [embed] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+5
-5
@@ -57,23 +57,23 @@ export async function run(message, data) {
|
|||||||
const searchEmbed = new EmbedBuilder()
|
const searchEmbed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription("🔍 Searching...")
|
.setDescription("🔍 Searching...")
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
let statusMsg = null;
|
let statusMsg = null;
|
||||||
try {
|
try {
|
||||||
statusMsg = await message.replyEmbed({ embeds: [searchEmbed] });
|
statusMsg = await message.reply({ embeds: [searchEmbed] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Fluxer API timed out sending the status message — continue without it
|
// Fluxer API timed out sending the status message — continue without it
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages = p.play(query, false, provider);
|
const messages = p.play(query, false, provider);
|
||||||
messages.on("message", d => {
|
messages.on("message", d => {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(d).toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(d);
|
||||||
if (statusMsg) {
|
if (statusMsg) {
|
||||||
statusMsg.editEmbed({ embeds: [embed] }).catch(() => {});
|
statusMsg.edit({ embeds: [embed] }).catch(() => {});
|
||||||
} else {
|
} else {
|
||||||
// statusMsg failed to send earlier, fall back to a fresh reply
|
// statusMsg failed to send earlier, fall back to a fresh reply
|
||||||
message.replyEmbed({ embeds: [embed] }).catch(() => {});
|
message.reply({ embeds: [embed] }).catch(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+12
-12
@@ -141,10 +141,10 @@ export async function run(msg) {
|
|||||||
});
|
});
|
||||||
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
|
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
|
||||||
if (current?.thumbnail) builder.setThumbnail(current.thumbnail);
|
if (current?.thumbnail) builder.setThumbnail(current.thumbnail);
|
||||||
return builder.toJSON();
|
return builder;
|
||||||
};
|
};
|
||||||
|
|
||||||
const message = await msg.replyEmbed({ embeds: [buildEmbed()] });
|
const message = await msg.reply({ embeds: [buildEmbed()] });
|
||||||
if (!message?.message) return;
|
if (!message?.message) return;
|
||||||
|
|
||||||
for (const row of controlsLayout) {
|
for (const row of controlsLayout) {
|
||||||
@@ -183,7 +183,7 @@ export async function run(msg) {
|
|||||||
await clearReactions();
|
await clearReactions();
|
||||||
const disabledEmbed = buildEmbed({ message: "⌛ Controls disabled (react to re-enable)" });
|
const disabledEmbed = buildEmbed({ message: "⌛ Controls disabled (react to re-enable)" });
|
||||||
disabledEmbed.footer = { text: "Controls expired • React to refresh" };
|
disabledEmbed.footer = { text: "Controls expired • React to refresh" };
|
||||||
await message.editEmbed({ embeds: [disabledEmbed] }).catch(() => {});
|
await message.edit({ embeds: [disabledEmbed] }).catch(() => {});
|
||||||
}, EMOJI_REMOVE_TIMEOUT);
|
}, EMOJI_REMOVE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ export async function run(msg) {
|
|||||||
|
|
||||||
const refresh = (extra = {}) => {
|
const refresh = (extra = {}) => {
|
||||||
const embed = buildEmbed(extra);
|
const embed = buildEmbed(extra);
|
||||||
message.editEmbed({ embeds: [embed] }).catch(() => {});
|
message.edit({ embeds: [embed] }).catch(() => {});
|
||||||
lastState = extra;
|
lastState = extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ export async function run(msg) {
|
|||||||
closedEmbed.footer = { text: "Session ended" };
|
closedEmbed.footer = { text: "Session ended" };
|
||||||
closedEmbed.title = "🎧 Music Player (Inactive)";
|
closedEmbed.title = "🎧 Music Player (Inactive)";
|
||||||
|
|
||||||
await message.editEmbed({
|
await message.edit({
|
||||||
embeds: [closedEmbed],
|
embeds: [closedEmbed],
|
||||||
content: reason === "user" ? "👋 Player controls closed" : undefined
|
content: reason === "user" ? "👋 Player controls closed" : undefined
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
@@ -420,10 +420,10 @@ export async function run(msg) {
|
|||||||
totalPages > 1 && !expired && !closed ? `\n\n💡 ⬅️ ➡️ Navigate • ❌ Close` : '',
|
totalPages > 1 && !expired && !closed ? `\n\n💡 ⬅️ ➡️ Navigate • ❌ Close` : '',
|
||||||
'```'
|
'```'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).setFooter({ text: footerText }).toJSON()] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).setFooter({ text: footerText })] };
|
||||||
};
|
};
|
||||||
|
|
||||||
activeLyricsMsg = await msg.replyEmbed(buildLyricsContent(0));
|
activeLyricsMsg = await msg.reply(buildLyricsContent(0));
|
||||||
|
|
||||||
if (activeLyricsMsg?.message && totalPages > 1) {
|
if (activeLyricsMsg?.message && totalPages > 1) {
|
||||||
const navEmojis = ["⬅️", "➡️", "❌"];
|
const navEmojis = ["⬅️", "➡️", "❌"];
|
||||||
@@ -435,7 +435,7 @@ export async function run(msg) {
|
|||||||
clearTimeout(lyricsEmojiTimeout);
|
clearTimeout(lyricsEmojiTimeout);
|
||||||
lyricsEmojiTimeout = setTimeout(async () => {
|
lyricsEmojiTimeout = setTimeout(async () => {
|
||||||
await clearLyricsReactions(activeLyricsMsg);
|
await clearLyricsReactions(activeLyricsMsg);
|
||||||
await activeLyricsMsg.editEmbed(buildLyricsContent(currentPage, true, false)).catch(() => {});
|
await activeLyricsMsg.edit(buildLyricsContent(currentPage, true, false)).catch(() => {});
|
||||||
}, EMOJI_REMOVE_TIMEOUT);
|
}, EMOJI_REMOVE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -444,7 +444,7 @@ export async function run(msg) {
|
|||||||
lyricsUnobserve();
|
lyricsUnobserve();
|
||||||
clearTimeout(lyricsEmojiTimeout);
|
clearTimeout(lyricsEmojiTimeout);
|
||||||
await clearLyricsReactions(activeLyricsMsg);
|
await clearLyricsReactions(activeLyricsMsg);
|
||||||
await activeLyricsMsg.editEmbed(buildLyricsContent(currentPage, false, true)).catch(() => {});
|
await activeLyricsMsg.edit(buildLyricsContent(currentPage, false, true)).catch(() => {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ export async function run(msg) {
|
|||||||
currentPage = currentPage < totalPages - 1 ? currentPage + 1 : 0;
|
currentPage = currentPage < totalPages - 1 ? currentPage + 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
await activeLyricsMsg.editEmbed(buildLyricsContent(currentPage));
|
await activeLyricsMsg.edit(buildLyricsContent(currentPage));
|
||||||
});
|
});
|
||||||
|
|
||||||
resetLyricsTimer();
|
resetLyricsTimer();
|
||||||
@@ -467,7 +467,7 @@ export async function run(msg) {
|
|||||||
clearTimeout(lyricsEmojiTimeout);
|
clearTimeout(lyricsEmojiTimeout);
|
||||||
lyricsEmojiTimeout = setTimeout(async () => {
|
lyricsEmojiTimeout = setTimeout(async () => {
|
||||||
await clearLyricsReactions(activeLyricsMsg);
|
await clearLyricsReactions(activeLyricsMsg);
|
||||||
await activeLyricsMsg.editEmbed(buildLyricsContent(0, true, false)).catch(() => {});
|
await activeLyricsMsg.edit(buildLyricsContent(0, true, false)).catch(() => {});
|
||||||
}, EMOJI_REMOVE_TIMEOUT);
|
}, EMOJI_REMOVE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -476,7 +476,7 @@ export async function run(msg) {
|
|||||||
lyricsUnobserve();
|
lyricsUnobserve();
|
||||||
clearTimeout(lyricsEmojiTimeout);
|
clearTimeout(lyricsEmojiTimeout);
|
||||||
await clearLyricsReactions(activeLyricsMsg);
|
await clearLyricsReactions(activeLyricsMsg);
|
||||||
await activeLyricsMsg.editEmbed(buildLyricsContent(0, false, true)).catch(() => {});
|
await activeLyricsMsg.edit(buildLyricsContent(0, false, true)).catch(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ export async function run(message, data) {
|
|||||||
const searchEmbed = new EmbedBuilder()
|
const searchEmbed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription("🔍 Searching...")
|
.setDescription("🔍 Searching...")
|
||||||
.toJSON();
|
;
|
||||||
const statusMsg = await message.replyEmbed({ embeds: [searchEmbed] });
|
const statusMsg = await message.reply({ embeds: [searchEmbed] });
|
||||||
|
|
||||||
const messages = p.playFirst(query, provider);
|
const messages = p.playFirst(query, provider);
|
||||||
messages.on("message", d => {
|
messages.on("message", d => {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(d).toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(d);
|
||||||
statusMsg.editEmbed({ embeds: [embed] }).catch(() => {});
|
statusMsg.edit({ embeds: [embed] }).catch(() => {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+10
-10
@@ -10,7 +10,7 @@ const NEXT_EMOJI = "➡️";
|
|||||||
function mkEmbed(desc, title) {
|
function mkEmbed(desc, title) {
|
||||||
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
||||||
if (title) b.setTitle(title);
|
if (title) b.setTitle(title);
|
||||||
return { embeds: [b.toJSON()] };
|
return { embeds: [b] };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const command = function() {
|
export const command = function() {
|
||||||
@@ -29,7 +29,7 @@ export const command = function() {
|
|||||||
|
|
||||||
export async function run(msg, data) {
|
export async function run(msg, data) {
|
||||||
const radios = this.config.radio;
|
const radios = this.config.radio;
|
||||||
if (!radios?.length) return msg.replyEmbed(mkEmbed("❌ No radio stations are configured."));
|
if (!radios?.length) return msg.reply(mkEmbed("❌ No radio stations are configured."));
|
||||||
|
|
||||||
const input = (data.get("station")?.value ?? "").trim().toLowerCase();
|
const input = (data.get("station")?.value ?? "").trim().toLowerCase();
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ export async function run(msg, data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let { payload, pickable } = buildPage();
|
let { payload, pickable } = buildPage();
|
||||||
const listMsg = await msg.replyEmbed(payload);
|
const listMsg = await msg.reply(payload);
|
||||||
if (!listMsg) return;
|
if (!listMsg) return;
|
||||||
|
|
||||||
const baseEmojis = [...NUMBER_EMOJIS, PREV_EMOJI, NEXT_EMOJI, CANCEL_EMOJI];
|
const baseEmojis = [...NUMBER_EMOJIS, PREV_EMOJI, NEXT_EMOJI, CANCEL_EMOJI];
|
||||||
@@ -78,7 +78,7 @@ export async function run(msg, data) {
|
|||||||
settled = true;
|
settled = true;
|
||||||
unobserve();
|
unobserve();
|
||||||
clearReactions().catch(() => {});
|
clearReactions().catch(() => {});
|
||||||
listMsg.editEmbed(mkEmbed("📻 Radio selection timed out.")).catch(() => {});
|
listMsg.edit(mkEmbed("📻 Radio selection timed out.")).catch(() => {});
|
||||||
}, 60_000);
|
}, 60_000);
|
||||||
|
|
||||||
const normalize = (s) => s.replace(/\uFE0F/g, "");
|
const normalize = (s) => s.replace(/\uFE0F/g, "");
|
||||||
@@ -92,7 +92,7 @@ export async function run(msg, data) {
|
|||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
unobserve();
|
unobserve();
|
||||||
await clearReactions();
|
await clearReactions();
|
||||||
listMsg.editEmbed(mkEmbed("❌ Radio selection cancelled.")).catch(() => {});
|
listMsg.edit(mkEmbed("❌ Radio selection cancelled.")).catch(() => {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (emoji === normalize(NEXT_EMOJI)) page = (page + 1) % totalPages;
|
if (emoji === normalize(NEXT_EMOJI)) page = (page + 1) % totalPages;
|
||||||
@@ -111,7 +111,7 @@ export async function run(msg, data) {
|
|||||||
|
|
||||||
const next = buildPage();
|
const next = buildPage();
|
||||||
pickable = next.pickable;
|
pickable = next.pickable;
|
||||||
await listMsg.editEmbed(next.payload).catch(() => {});
|
await listMsg.edit(next.payload).catch(() => {});
|
||||||
}, msg.author);
|
}, msg.author);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -121,7 +121,7 @@ export async function run(msg, data) {
|
|||||||
const radio = radios.find(r => r.name.toLowerCase() === input);
|
const radio = radios.find(r => r.name.toLowerCase() === input);
|
||||||
if (!radio) {
|
if (!radio) {
|
||||||
const names = radios.map(r => `\`${r.name}\``).join(", ");
|
const names = radios.map(r => `\`${r.name}\``).join(", ");
|
||||||
return msg.replyEmbed(mkEmbed(`❌ Unknown station \`${input}\`. Available: ${names}\n\nUse \`%radio list\` to browse.`));
|
return msg.reply(mkEmbed(`❌ Unknown station \`${input}\`. Available: ${names}\n\nUse \`%radio list\` to browse.`));
|
||||||
}
|
}
|
||||||
return playStation(this, msg, radio);
|
return playStation(this, msg, radio);
|
||||||
}
|
}
|
||||||
@@ -146,8 +146,8 @@ async function playStation(ctx, msg, radio, editTarget = null) {
|
|||||||
`${radio.description}\n\n` +
|
`${radio.description}\n\n` +
|
||||||
`_Use \`%skip\` to stop the radio, or \`%radio list\` to switch stations._`
|
`_Use \`%skip\` to stop the radio, or \`%radio list\` to switch stations._`
|
||||||
)
|
)
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
if (editTarget) editTarget.editEmbed({ embeds: [embed] }).catch(() => {});
|
if (editTarget) editTarget.edit({ embeds: [embed] }).catch(() => {});
|
||||||
else msg.replyEmbed({ embeds: [embed] }).catch(() => {});
|
else msg.reply({ embeds: [embed] }).catch(() => {});
|
||||||
}
|
}
|
||||||
+7
-7
@@ -17,7 +17,7 @@ export const command = new CommandBuilder()
|
|||||||
.setRequirement(r => r.setOwnerOnly(true));
|
.setRequirement(r => r.setOwnerOnly(true));
|
||||||
|
|
||||||
function embed(desc) {
|
function embed(desc) {
|
||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).toJSON()] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
||||||
@@ -101,11 +101,11 @@ async function showPaged(msg, title, lines, pageSize = 14) {
|
|||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setDescription(pages[n].join("\n") + (pages.length > 1 ? `\n\nPage **${n + 1}** / **${pages.length}**` : ""))
|
.setDescription(pages[n].join("\n") + (pages.length > 1 ? `\n\nPage **${n + 1}** / **${pages.length}**` : ""))
|
||||||
.toJSON()
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const m = await msg.replyEmbed(mkEmbed(0));
|
const m = await msg.reply(mkEmbed(0));
|
||||||
if (!m || pages.length <= 1) return;
|
if (!m || pages.length <= 1) return;
|
||||||
|
|
||||||
m.message.react(arrows[0]).catch(() => {});
|
m.message.react(arrows[0]).catch(() => {});
|
||||||
@@ -114,7 +114,7 @@ async function showPaged(msg, title, lines, pageSize = 14) {
|
|||||||
const unsub = m.onReaction(arrows, (e) => {
|
const unsub = m.onReaction(arrows, (e) => {
|
||||||
if (e.emoji_id === arrows[0]) curr.n = Math.max(0, curr.n - 1);
|
if (e.emoji_id === arrows[0]) curr.n = Math.max(0, curr.n - 1);
|
||||||
else curr.n = Math.min(pages.length - 1, curr.n + 1);
|
else curr.n = Math.min(pages.length - 1, curr.n + 1);
|
||||||
m.editEmbed(mkEmbed(curr.n)).catch(() => {});
|
m.edit(mkEmbed(curr.n)).catch(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => { unsub?.(); }, 5 * 60_000);
|
setTimeout(() => { unsub?.(); }, 5 * 60_000);
|
||||||
@@ -184,7 +184,7 @@ export async function run(msg, data) {
|
|||||||
// Single command by name
|
// Single command by name
|
||||||
if (this.handler.commands.some(c => c.name === target)) {
|
if (this.handler.commands.some(c => c.name === target)) {
|
||||||
const res = await reloadCommand(this, target);
|
const res = await reloadCommand(this, target);
|
||||||
return msg.replyEmbed(embed(res.msg));
|
return msg.reply(embed(res.msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Single src/ or audio/ module by filename (with or without extension/subdir)
|
// Single src/ or audio/ module by filename (with or without extension/subdir)
|
||||||
@@ -196,10 +196,10 @@ export async function run(msg, data) {
|
|||||||
|
|
||||||
if (mod) {
|
if (mod) {
|
||||||
const res = await reloadModule(this, mod.file, mod.label);
|
const res = await reloadModule(this, mod.file, mod.label);
|
||||||
return msg.replyEmbed(embed(res.msg));
|
return msg.reply(embed(res.msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg.replyEmbed(embed(
|
return msg.reply(embed(
|
||||||
`❌ Unknown target \`${target}\`.\nRun \`%reload\` with no arguments to see all reloadable targets.`
|
`❌ Unknown target \`${target}\`.\nRun \`%reload\` with no arguments to see all reloadable targets.`
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
+2
-2
@@ -18,6 +18,6 @@ export async function run(message, data) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription(res)
|
.setDescription(res)
|
||||||
.toJSON();
|
;
|
||||||
message.replyEmbed({ embeds: [embed] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+2
-2
@@ -14,6 +14,6 @@ export async function run(message) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription(res)
|
.setDescription(res)
|
||||||
.toJSON();
|
;
|
||||||
message.replyEmbed({ embeds: [embed] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+1
-1
@@ -69,7 +69,7 @@ export async function run(msg, data) {
|
|||||||
.setAuthor({ name: authorLabel })
|
.setAuthor({ name: authorLabel })
|
||||||
.setDescription(description);
|
.setDescription(description);
|
||||||
if (footerText) b.setFooter({ text: footerText });
|
if (footerText) b.setFooter({ text: footerText });
|
||||||
return b.toJSON();
|
return b;
|
||||||
};
|
};
|
||||||
|
|
||||||
const nativeMsg = msg.message ?? msg;
|
const nativeMsg = msg.message ?? msg;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const command = new CommandBuilder()
|
|||||||
const EMOJI_REMOVE_TIMEOUT = 60000;
|
const EMOJI_REMOVE_TIMEOUT = 60000;
|
||||||
|
|
||||||
export async function run(msg) {
|
export async function run(msg) {
|
||||||
const guilds = [...this.client.guilds.cache.values()];
|
const guilds = [...this.client.guilds.values()];
|
||||||
|
|
||||||
// Fallback if the bot is in 0 servers
|
// Fallback if the bot is in 0 servers
|
||||||
if (guilds.length === 0) {
|
if (guilds.length === 0) {
|
||||||
@@ -20,8 +20,8 @@ export async function run(msg) {
|
|||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setTitle("🌐 Servers (0)")
|
.setTitle("🌐 Servers (0)")
|
||||||
.setDescription("_No servers found._")
|
.setDescription("_No servers found._")
|
||||||
.toJSON();
|
;
|
||||||
return msg.replyEmbed({ embeds: [emptyEmbed] });
|
return msg.reply({ embeds: [emptyEmbed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemsPerPage = 50;
|
const itemsPerPage = 50;
|
||||||
@@ -50,13 +50,13 @@ export async function run(msg) {
|
|||||||
? "💡 ⬅️ ➡️ Navigate"
|
? "💡 ⬅️ ➡️ Navigate"
|
||||||
: "List complete"
|
: "List complete"
|
||||||
})
|
})
|
||||||
.toJSON();
|
;
|
||||||
|
|
||||||
return { embeds: [embed] };
|
return { embeds: [embed] };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send the initial message using the framework's wrapper
|
// Send the initial message using the framework's wrapper
|
||||||
const replyMsg = await msg.replyEmbed(buildPageContent(0));
|
const replyMsg = await msg.reply(buildPageContent(0));
|
||||||
|
|
||||||
// Safety check and single-page exit
|
// Safety check and single-page exit
|
||||||
if (!replyMsg?.message) return;
|
if (!replyMsg?.message) return;
|
||||||
@@ -90,7 +90,7 @@ export async function run(msg) {
|
|||||||
emojiTimeout = setTimeout(async () => {
|
emojiTimeout = setTimeout(async () => {
|
||||||
if (unobserve) unobserve();
|
if (unobserve) unobserve();
|
||||||
await clearReactions();
|
await clearReactions();
|
||||||
await replyMsg.editEmbed(buildPageContent(currentPage, true)).catch(() => {});
|
await replyMsg.edit(buildPageContent(currentPage, true)).catch(() => {});
|
||||||
}, EMOJI_REMOVE_TIMEOUT);
|
}, EMOJI_REMOVE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export async function run(msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the embed using the framework's native edit method
|
// Update the embed using the framework's native edit method
|
||||||
await replyMsg.editEmbed(buildPageContent(currentPage)).catch(() => {});
|
await replyMsg.edit(buildPageContent(currentPage)).catch(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start the initial countdown
|
// Start the initial countdown
|
||||||
|
|||||||
+24
-24
@@ -7,7 +7,7 @@ function embed(desc, opts = {}) {
|
|||||||
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
||||||
if (opts.title) b.setTitle(opts.title);
|
if (opts.title) b.setTitle(opts.title);
|
||||||
if (opts.iconURL) b.setAuthor({ name: opts.title || "\u200b", iconURL: opts.iconURL });
|
if (opts.iconURL) b.setAuthor({ name: opts.title || "\u200b", iconURL: opts.iconURL });
|
||||||
return { embeds: [b.toJSON()] };
|
return { embeds: [b] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Constants ─────────────────────────────────────────────────────────────────
|
// ── Constants ─────────────────────────────────────────────────────────────────
|
||||||
@@ -148,7 +148,7 @@ async function handle247(ctx, message, value) {
|
|||||||
const resolved = mode === "true" ? "auto" : mode === "false" ? "off" : mode;
|
const resolved = mode === "true" ? "auto" : mode === "false" ? "off" : mode;
|
||||||
|
|
||||||
if (!["off", "on", "auto"].includes(resolved)) {
|
if (!["off", "on", "auto"].includes(resolved)) {
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`❌ Invalid value \`${value}\` for 24/7 mode.\n\n` +
|
`❌ Invalid value \`${value}\` for 24/7 mode.\n\n` +
|
||||||
`**Valid options:**\n` +
|
`**Valid options:**\n` +
|
||||||
`• \`off\` — bot leaves after inactivity\n` +
|
`• \`off\` — bot leaves after inactivity\n` +
|
||||||
@@ -159,7 +159,7 @@ async function handle247(ctx, message, value) {
|
|||||||
|
|
||||||
// ── OFF ───────────────────────────────────────────────────────────────────
|
// ── OFF ───────────────────────────────────────────────────────────────────
|
||||||
if (resolved === "off") {
|
if (resolved === "off") {
|
||||||
if (!guildId) return message.replyEmbed(embed("❌ Could not detect your server."));
|
if (!guildId) return message.reply(embed("❌ Could not detect your server."));
|
||||||
|
|
||||||
const channelId = ctx.players.checkVoiceChannels(message);
|
const channelId = ctx.players.checkVoiceChannels(message);
|
||||||
const channels = get247Channels(set);
|
const channels = get247Channels(set);
|
||||||
@@ -186,7 +186,7 @@ async function handle247(ctx, message, value) {
|
|||||||
const extra = remaining.length > 0
|
const extra = remaining.length > 0
|
||||||
? `\nSaved channels left: ${remaining.map(ch => `<#${ch}>`).join(", ")}`
|
? `\nSaved channels left: ${remaining.map(ch => `<#${ch}>`).join(", ")}`
|
||||||
: "";
|
: "";
|
||||||
return message.replyEmbed(embed(`✅ 24/7 mode **disabled** for <#${id}>. Bot has left.${extra}`));
|
return message.reply(embed(`✅ 24/7 mode **disabled** for <#${id}>. Bot has left.${extra}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not in a channel — disable all for this guild
|
// Not in a channel — disable all for this guild
|
||||||
@@ -202,15 +202,15 @@ async function handle247(ctx, message, value) {
|
|||||||
player.destroy();
|
player.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return message.replyEmbed(embed("✅ 24/7 mode **disabled** for all channels in this server."));
|
return message.reply(embed("✅ 24/7 mode **disabled** for all channels in this server."));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── ON / AUTO ─────────────────────────────────────────────────────────────
|
// ── ON / AUTO ─────────────────────────────────────────────────────────────
|
||||||
if (!guildId) return message.replyEmbed(embed("❌ Could not detect your server."));
|
if (!guildId) return message.reply(embed("❌ Could not detect your server."));
|
||||||
|
|
||||||
const channelId = ctx.players.checkVoiceChannels(message);
|
const channelId = ctx.players.checkVoiceChannels(message);
|
||||||
if (!channelId) {
|
if (!channelId) {
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`❌ You're not in a voice channel. Join one first, then run \`%247 ${resolved}\` again.`
|
`❌ You're not in a voice channel. Join one first, then run \`%247 ${resolved}\` again.`
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -234,14 +234,14 @@ async function handle247(ctx, message, value) {
|
|||||||
cleanId(p?._channelId ?? "") === id && cleanId(p?._guildId ?? "") === cleanId(guildId)
|
cleanId(p?._channelId ?? "") === id && cleanId(p?._guildId ?? "") === cleanId(guildId)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return message.replyEmbed(embed(`✅ 24/7 mode set to ${modeLabel} for <#${id}>.\n${savedSummary}`));
|
return message.reply(embed(`✅ 24/7 mode set to ${modeLabel} for <#${id}>.\n${savedSummary}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ctx._spawnPlayer(guildId, id);
|
await ctx._spawnPlayer(guildId, id);
|
||||||
return message.replyEmbed(embed(`✅ 24/7 mode set to ${modeLabel} for <#${id}>. Bot joined!\n${savedSummary}`));
|
return message.reply(embed(`✅ 24/7 mode set to ${modeLabel} for <#${id}>. Bot joined!\n${savedSummary}`));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return message.replyEmbed(embed(`✅ 24/7 mode saved for <#${id}>, but failed to join: ${e.message}\n${savedSummary}`));
|
return message.reply(embed(`✅ 24/7 mode saved for <#${id}>, but failed to join: ${e.message}\n${savedSummary}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,21 +322,21 @@ async function handleShortcut(ctx, message, settingKey, valueTokens) {
|
|||||||
// GET (no value provided)
|
// GET (no value provided)
|
||||||
if (valueTokens.length === 0) {
|
if (valueTokens.length === 0) {
|
||||||
if (settingKey === "stay_247") {
|
if (settingKey === "stay_247") {
|
||||||
return message.replyEmbed(embed(`24/7 mode: ${format247Status(set)}`));
|
return message.reply(embed(`24/7 mode: ${format247Status(set)}`));
|
||||||
}
|
}
|
||||||
const val = set.get(settingKey);
|
const val = set.get(settingKey);
|
||||||
return message.replyEmbed(embed(`\`${settingKey}\` → ${displayValue(settingKey, val)}`));
|
return message.reply(embed(`\`${settingKey}\` → ${displayValue(settingKey, val)}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
// SET
|
// SET
|
||||||
const rawValue = valueTokens.join(" ");
|
const rawValue = valueTokens.join(" ");
|
||||||
const err = await applySet(ctx, message, set, settingKey, rawValue);
|
const err = await applySet(ctx, message, set, settingKey, rawValue);
|
||||||
if (err) return message.replyEmbed(embed(err));
|
if (err) return message.reply(embed(err));
|
||||||
|
|
||||||
// handle247 replies on its own
|
// handle247 replies on its own
|
||||||
if (settingKey !== "stay_247") {
|
if (settingKey !== "stay_247") {
|
||||||
const val = set.get(settingKey);
|
const val = set.get(settingKey);
|
||||||
return message.replyEmbed(embed(`✅ \`${settingKey}\` set to ${displayValue(settingKey, val)}`));
|
return message.reply(embed(`✅ \`${settingKey}\` set to ${displayValue(settingKey, val)}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,31 +469,31 @@ export async function run(message, data) {
|
|||||||
|
|
||||||
if (!this.settingsMgr.isOption(settingKey)) {
|
if (!this.settingsMgr.isOption(settingKey)) {
|
||||||
const available = Object.keys(this.settingsMgr.defaults).join("`, `");
|
const available = Object.keys(this.settingsMgr.defaults).join("`, `");
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`❌ Unknown setting \`${settingKey}\`.\nAvailable: \`${available}\``
|
`❌ Unknown setting \`${settingKey}\`.\nAvailable: \`${available}\``
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const err = await applySet(this, message, set, settingKey, rawValue);
|
const err = await applySet(this, message, set, settingKey, rawValue);
|
||||||
if (err) return message.replyEmbed(embed(err));
|
if (err) return message.reply(embed(err));
|
||||||
|
|
||||||
if (settingKey === "stay_247") return; // handle247 replied already
|
if (settingKey === "stay_247") return; // handle247 replied already
|
||||||
|
|
||||||
const newVal = set.get(settingKey);
|
const newVal = set.get(settingKey);
|
||||||
return message.replyEmbed(embed(`✅ **${prettifySettingLabel(settingKey)}** set to ${displayValue(settingKey, newVal)}`));
|
return message.reply(embed(`✅ **${prettifySettingLabel(settingKey)}** set to ${displayValue(settingKey, newVal)}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── get ───────────────────────────────────────────────────────────────────
|
// ── get ───────────────────────────────────────────────────────────────────
|
||||||
if (cmd === "getSettings") {
|
if (cmd === "getSettings") {
|
||||||
if (settingKey) {
|
if (settingKey) {
|
||||||
if (settingKey === "stay_247") {
|
if (settingKey === "stay_247") {
|
||||||
return message.replyEmbed(embed(format247Summary(set)));
|
return message.reply(embed(format247Summary(set)));
|
||||||
}
|
}
|
||||||
const val = set.get(settingKey);
|
const val = set.get(settingKey);
|
||||||
const description = this.settingsMgr.descriptions?.[settingKey];
|
const description = this.settingsMgr.descriptions?.[settingKey];
|
||||||
let reply = `**${prettifySettingLabel(settingKey)}**\nValue: ${displayValue(settingKey, val)}`;
|
let reply = `**${prettifySettingLabel(settingKey)}**\nValue: ${displayValue(settingKey, val)}`;
|
||||||
if (description) reply += `\n\n*${description}*`;
|
if (description) reply += `\n\n*${description}*`;
|
||||||
return message.replyEmbed(embed(reply));
|
return message.reply(embed(reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
// List all settings
|
// List all settings
|
||||||
@@ -515,7 +515,7 @@ export async function run(message, data) {
|
|||||||
return `• **${prettifySettingLabel(k)}** — ${displayValue(k, d[k])}`;
|
return `• **${prettifySettingLabel(k)}** — ${displayValue(k, d[k])}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`Server: **${guildName}**\n\n${lines.join("\n")}\n\n` +
|
`Server: **${guildName}**\n\n${lines.join("\n")}\n\n` +
|
||||||
`Shortcuts: \`${prefix}247\`, \`${prefix}prefix\`\n` +
|
`Shortcuts: \`${prefix}247\`, \`${prefix}prefix\`\n` +
|
||||||
`Use \`${prefix}settings help <setting>\` to learn about any setting.`,
|
`Use \`${prefix}settings help <setting>\` to learn about any setting.`,
|
||||||
@@ -526,11 +526,11 @@ export async function run(message, data) {
|
|||||||
// ── reset ─────────────────────────────────────────────────────────────────
|
// ── reset ─────────────────────────────────────────────────────────────────
|
||||||
if (cmd === "resetSettings") {
|
if (cmd === "resetSettings") {
|
||||||
if (!this.settingsMgr.isOption(settingKey)) {
|
if (!this.settingsMgr.isOption(settingKey)) {
|
||||||
return message.replyEmbed(embed(`❌ Unknown setting \`${settingKey}\`.`));
|
return message.reply(embed(`❌ Unknown setting \`${settingKey}\`.`));
|
||||||
}
|
}
|
||||||
set.reset(settingKey);
|
set.reset(settingKey);
|
||||||
const def = set.get(settingKey);
|
const def = set.get(settingKey);
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`🔄 \`${settingKey}\` has been reset to its default: ${displayValue(settingKey, def)}`
|
`🔄 \`${settingKey}\` has been reset to its default: ${displayValue(settingKey, def)}`
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -542,7 +542,7 @@ export async function run(message, data) {
|
|||||||
if (!settingKey) {
|
if (!settingKey) {
|
||||||
const keys = Object.keys(this.settingsMgr.defaults);
|
const keys = Object.keys(this.settingsMgr.defaults);
|
||||||
const keyList = keys.map(k => `\`${k}\``).join(", ");
|
const keyList = keys.map(k => `\`${k}\``).join(", ");
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`**⚙️ Settings Help**\n\n` +
|
`**⚙️ Settings Help**\n\n` +
|
||||||
`**Available settings:** ${keyList}\n\n` +
|
`**Available settings:** ${keyList}\n\n` +
|
||||||
`**Subcommands:**\n` +
|
`**Subcommands:**\n` +
|
||||||
@@ -571,7 +571,7 @@ export async function run(message, data) {
|
|||||||
extra = `\n**Valid values:** \`off\`, \`on\`, \`auto\`\n**Tip:** You can save more than one voice channel in the same server.`;
|
extra = `\n**Valid values:** \`off\`, \`on\`, \`auto\`\n**Tip:** You can save more than one voice channel in the same server.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return message.replyEmbed(embed(
|
return message.reply(embed(
|
||||||
`**⚙️ Setting: \`${settingKey}\`**\n\n` +
|
`**⚙️ Setting: \`${settingKey}\`**\n\n` +
|
||||||
`${description}${extra}\n\n` +
|
`${description}${extra}\n\n` +
|
||||||
`**Current value:** ${settingKey === "stay_247" ? format247Status(set) : displayValue(settingKey, currentVal)}\n` +
|
`**Current value:** ${settingKey === "stay_247" ? format247Status(set) : displayValue(settingKey, currentVal)}\n` +
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ export async function run(message) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription(res)
|
.setDescription(res)
|
||||||
.toJSON();
|
;
|
||||||
message.replyEmbed({ embeds: [embed] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+4
-4
@@ -18,8 +18,8 @@ export async function run(message) {
|
|||||||
|
|
||||||
const err = p.skip();
|
const err = p.skip();
|
||||||
if (err && err.includes("nothing playing")) {
|
if (err && err.includes("nothing playing")) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(err).toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(err);
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
return message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const desc = skippedTitle
|
const desc = skippedTitle
|
||||||
@@ -29,6 +29,6 @@ export async function run(message) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setDescription(desc)
|
.setDescription(desc)
|
||||||
.toJSON();
|
;
|
||||||
message.replyEmbed({ embeds: [embed] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+5
-5
@@ -58,7 +58,7 @@ async function fetchGuildMemberCount(guild) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function refreshUserCount(client) {
|
async function refreshUserCount(client) {
|
||||||
const guilds = [...client.guilds.cache.values()];
|
const guilds = [...client.guilds.values()];
|
||||||
const counts = await pool(10, guilds.map(g => () => fetchGuildMemberCount(g)));
|
const counts = await pool(10, guilds.map(g => () => fetchGuildMemberCount(g)));
|
||||||
cachedUserCount = counts.reduce((a, b) => a + b, 0);
|
cachedUserCount = counts.reduce((a, b) => a + b, 0);
|
||||||
cacheExpiresAt = Date.now() + CACHE_TTL_MS;
|
cacheExpiresAt = Date.now() + CACHE_TTL_MS;
|
||||||
@@ -113,14 +113,14 @@ function buildEmbed({ guildCount, userCount, playerCount, ping, uptime, comHash,
|
|||||||
.setFooter({ text: footer || "Remix Music Bot" });
|
.setFooter({ text: footer || "Remix Music Bot" });
|
||||||
|
|
||||||
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
|
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
|
||||||
return builder.toJSON();
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Runner ────────────────────────────────────────────────────────────────────
|
// ── Runner ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export async function run(message) {
|
export async function run(message) {
|
||||||
const shared = {
|
const shared = {
|
||||||
guildCount: this.client.guilds.cache.size,
|
guildCount: this.client.guilds.size,
|
||||||
playerCount: getLivePlayerCount(this.players.playerMap),
|
playerCount: getLivePlayerCount(this.players.playerMap),
|
||||||
uptime: Utils.prettifyMS(Math.round(process.uptime()) * 1000),
|
uptime: Utils.prettifyMS(Math.round(process.uptime()) * 1000),
|
||||||
comHash: this.comHash,
|
comHash: this.comHash,
|
||||||
@@ -133,14 +133,14 @@ export async function run(message) {
|
|||||||
|
|
||||||
// Measure real round-trip latency
|
// Measure real round-trip latency
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
const msg = await message.replyEmbed({
|
const msg = await message.reply({
|
||||||
embeds: [buildEmbed({ ...shared, userCount: hasCached ? cachedUserCount : 0, ping: 0, loading: !hasCached })]
|
embeds: [buildEmbed({ ...shared, userCount: hasCached ? cachedUserCount : 0, ping: 0, loading: !hasCached })]
|
||||||
});
|
});
|
||||||
const ping = Date.now() - start;
|
const ping = Date.now() - start;
|
||||||
|
|
||||||
const users = await getUserCount(this.client);
|
const users = await getUserCount(this.client);
|
||||||
|
|
||||||
await msg.editEmbed({
|
await msg.edit({
|
||||||
embeds: [buildEmbed({ ...shared, userCount: users, ping, loading: false })]
|
embeds: [buildEmbed({ ...shared, userCount: users, ping, loading: false })]
|
||||||
}).catch((err) => console.error("[stats] editEmbed failed:", err));
|
}).catch((err) => console.error("[stats] editEmbed failed:", err));
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,6 @@ export function run(msg) {
|
|||||||
"[Remix HQ](https://fluxer.gg/remix)\n\n" +
|
"[Remix HQ](https://fluxer.gg/remix)\n\n" +
|
||||||
"If you don't want to join, feel free to contact the team members listed in the server."
|
"If you don't want to join, feel free to contact the team members listed in the server."
|
||||||
)
|
)
|
||||||
.toJSON();
|
;
|
||||||
msg.replyEmbed({ embeds: [embed] });
|
msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+8
-8
@@ -10,8 +10,8 @@ export const command = new CommandBuilder()
|
|||||||
export async function run(msg, data) {
|
export async function run(msg, data) {
|
||||||
const guild = msg.channel?.channel?.guild ?? msg.message?.guild;
|
const guild = msg.channel?.channel?.guild ?? msg.message?.guild;
|
||||||
if (!guild) {
|
if (!guild) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ Must be used in a server.").toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("❌ Must be used in a server.");
|
||||||
return msg.replyEmbed({ embeds: [embed] });
|
return msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const channelCounts = new Map();
|
const channelCounts = new Map();
|
||||||
@@ -26,14 +26,14 @@ export async function run(msg, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (channelCounts.size === 0) {
|
if (channelCounts.size === 0) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("No one is in voice.").toJSON();
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription("No one is in voice.");
|
||||||
return msg.replyEmbed({ embeds: [embed] });
|
return msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const getChannelName = async (channelId) => {
|
const getChannelName = async (channelId) => {
|
||||||
const cached = this.client.channels.cache.get(channelId);
|
const cached = this.client.channels.get(channelId);
|
||||||
if (cached?.name) return cached.name;
|
if (cached?.name) return cached.name;
|
||||||
const guildCached = guild.channels?.cache?.get?.(channelId) ?? guild.channels?.get?.(channelId);
|
const guildCached = guild.channels?.get?.(channelId);
|
||||||
if (guildCached?.name) return guildCached.name;
|
if (guildCached?.name) return guildCached.name;
|
||||||
if (guild.channels) {
|
if (guild.channels) {
|
||||||
const all = typeof guild.channels.values === "function"
|
const all = typeof guild.channels.values === "function"
|
||||||
@@ -58,6 +58,6 @@ export async function run(msg, data) {
|
|||||||
.setColor(getGlobalColor())
|
.setColor(getGlobalColor())
|
||||||
.setTitle("🎙️ Voice Channel Members")
|
.setTitle("🎙️ Voice Channel Members")
|
||||||
.setDescription(desc.trim())
|
.setDescription(desc.trim())
|
||||||
.toJSON();
|
;
|
||||||
msg.replyEmbed({ embeds: [embed] });
|
msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
@@ -18,5 +18,5 @@ export async function run(msg) {
|
|||||||
.setDescription(data.msg);
|
.setDescription(data.msg);
|
||||||
if (data.image) embed.setImage(data.image);
|
if (data.image) embed.setImage(data.image);
|
||||||
|
|
||||||
msg.replyEmbed({ embeds: [embed.toJSON()] });
|
msg.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
+1
-1
@@ -37,5 +37,5 @@ export async function run(message, data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.replyEmbed({ embeds: [embed.toJSON()] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
@@ -60,5 +60,5 @@ export async function run(message, data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.replyEmbed({ embeds: [embed.toJSON()] });
|
message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ export class Remix {
|
|||||||
pendingSpawns.add(cleanChannelId);
|
pendingSpawns.add(cleanChannelId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let channel = client.channels.cache.get(cleanChannelId);
|
let channel = client.channels.get(cleanChannelId);
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
// voiceAdapterCreator is a concept and not meaningful in Fluxer.
|
// voiceAdapterCreator is a concept and not meaningful in Fluxer.
|
||||||
// A simple cache-miss check is sufficient — fetch only when not already cached.
|
// A simple cache-miss check is sufficient — fetch only when not already cached.
|
||||||
@@ -261,7 +261,7 @@ export class Remix {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!channel) { logger.warn("[PlayerSpawn] Channel not found:", cleanChannelId); return; }
|
if (!channel) { logger.warn("[PlayerSpawn] Channel not found:", cleanChannelId); return; }
|
||||||
client.channels.cache.set(cleanChannelId, channel);
|
client.channels.set(cleanChannelId, channel);
|
||||||
|
|
||||||
const p = new Player(this.config.token, {
|
const p = new Player(this.config.token, {
|
||||||
client: client,
|
client: client,
|
||||||
@@ -306,8 +306,8 @@ export class Remix {
|
|||||||
// 24/7 is off — send inactivity message with hint to enable 247
|
// 24/7 is off — send inactivity message with hint to enable 247
|
||||||
try {
|
try {
|
||||||
const prefix = this.handler?.getPrefix?.(guildId) ?? "%";
|
const prefix = this.handler?.getPrefix?.(guildId) ?? "%";
|
||||||
const guild = this.client.guilds.cache.get(guildId);
|
const guild = this.client.guilds.get(guildId);
|
||||||
const ch = guild?.channels?.cache?.find(c =>
|
const ch = guild?.channels?.find(c =>
|
||||||
(c.isTextBased?.() ?? c.channel_type === "TextChannel" ?? true) &&
|
(c.isTextBased?.() ?? c.channel_type === "TextChannel" ?? true) &&
|
||||||
(c.permissionsFor?.(this.client.user)?.has?.("SendMessages") ?? true)
|
(c.permissionsFor?.(this.client.user)?.has?.("SendMessages") ?? true)
|
||||||
);
|
);
|
||||||
@@ -332,7 +332,7 @@ export class Remix {
|
|||||||
const disabled = raw === false || raw === 0 ||
|
const disabled = raw === false || raw === 0 ||
|
||||||
["false", "0", "no", "off", "disable"].includes(String(raw).toLowerCase().trim());
|
["false", "0", "no", "off", "disable"].includes(String(raw).toLowerCase().trim());
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
const guild = this.client.guilds.cache.get(guildId);
|
const guild = this.client.guilds.get(guildId);
|
||||||
// Announcement channel lookup order:
|
// Announcement channel lookup order:
|
||||||
// 1. In-memory cache (fastest — populated on first find after startup)
|
// 1. In-memory cache (fastest — populated on first find after startup)
|
||||||
// 2. Persisted setting "announcementChannelId" (survives restarts)
|
// 2. Persisted setting "announcementChannelId" (survives restarts)
|
||||||
@@ -341,14 +341,14 @@ export class Remix {
|
|||||||
const cachedChId = this._announcementChannelCache.get(guildId)
|
const cachedChId = this._announcementChannelCache.get(guildId)
|
||||||
?? serverSet.get("announcementChannelId")
|
?? serverSet.get("announcementChannelId")
|
||||||
?? null;
|
?? null;
|
||||||
let ch = cachedChId ? guild?.channels?.cache?.get(String(cachedChId)) : null;
|
let ch = cachedChId ? guild?.channels?.get(String(cachedChId)) : null;
|
||||||
// if cached channel is gone (deleted/uncached), clear the stale
|
// if cached channel is gone (deleted/uncached), clear the stale
|
||||||
// entry immediately so we don't re-scan on every subsequent message event.
|
// entry immediately so we don't re-scan on every subsequent message event.
|
||||||
if (cachedChId && !ch) {
|
if (cachedChId && !ch) {
|
||||||
this._announcementChannelCache.delete(guildId);
|
this._announcementChannelCache.delete(guildId);
|
||||||
}
|
}
|
||||||
if (!ch) {
|
if (!ch) {
|
||||||
ch = guild?.channels?.cache?.find(c =>
|
ch = guild?.channels?.find(c =>
|
||||||
(c.isTextBased?.() ?? c.channel_type === "TextChannel" ?? true) &&
|
(c.isTextBased?.() ?? c.channel_type === "TextChannel" ?? true) &&
|
||||||
(c.permissionsFor?.(this.client.user)?.has?.("SendMessages") ?? true)
|
(c.permissionsFor?.(this.client.user)?.has?.("SendMessages") ?? true)
|
||||||
);
|
);
|
||||||
@@ -377,7 +377,7 @@ export class Remix {
|
|||||||
// ==== RESTORE STATE IF RECOVERING ====
|
// ==== RESTORE STATE IF RECOVERING ====
|
||||||
if (recoveryData) {
|
if (recoveryData) {
|
||||||
if (recoveryData.textChannelId) {
|
if (recoveryData.textChannelId) {
|
||||||
p.textChannel = client.channels.cache.get(recoveryData.textChannelId);
|
p.textChannel = client.channels.get(recoveryData.textChannelId);
|
||||||
}
|
}
|
||||||
if (recoveryData.home247ChannelId) {
|
if (recoveryData.home247ChannelId) {
|
||||||
p._home247Channel = normalizeChannelId(recoveryData.home247ChannelId) || cleanChannelId;
|
p._home247Channel = normalizeChannelId(recoveryData.home247ChannelId) || cleanChannelId;
|
||||||
@@ -567,13 +567,11 @@ export class Remix {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [gId, guild] of client.guilds.cache) {
|
for (const [gId, guild] of client.guilds) {
|
||||||
// guild.voice_states — raw snake_case array from @fluxerjs/core gateway payload (preferred).
|
// guild.voice_states — raw snake_case array from @fluxerjs/core gateway payload (preferred).
|
||||||
// guild.voiceStates?.cache — voiceStateManager collection (fallback, may not exist).
|
// guild.voiceStates — voiceStateManager collection (fallback).
|
||||||
// guild.voiceStates — bare iterable fallback if cache sub-property is absent.
|
|
||||||
const voiceStatesRaw =
|
const voiceStatesRaw =
|
||||||
guild.voice_states ??
|
guild.voice_states ??
|
||||||
guild.voiceStates?.cache ??
|
|
||||||
guild.voiceStates ??
|
guild.voiceStates ??
|
||||||
null;
|
null;
|
||||||
if (!voiceStatesRaw) continue;
|
if (!voiceStatesRaw) continue;
|
||||||
@@ -804,7 +802,6 @@ export class Remix {
|
|||||||
|
|
||||||
const voiceStatesRaw =
|
const voiceStatesRaw =
|
||||||
guild.voice_states ??
|
guild.voice_states ??
|
||||||
guild.voiceStates?.cache ??
|
|
||||||
guild.voiceStates ??
|
guild.voiceStates ??
|
||||||
null;
|
null;
|
||||||
if (voiceStatesRaw) {
|
if (voiceStatesRaw) {
|
||||||
@@ -908,7 +905,7 @@ export class Remix {
|
|||||||
logger.guild(`[GuildDelete] Removed from server ${guildId} — cleaning up.`);
|
logger.guild(`[GuildDelete] Removed from server ${guildId} — cleaning up.`);
|
||||||
|
|
||||||
// Use player._guildId directly instead of resolving the channel from
|
// Use player._guildId directly instead of resolving the channel from
|
||||||
// client.channels.cache (which may already be evicted at this point).
|
// client.channels (which may already be evicted at this point).
|
||||||
// The old approach fell through 4 property-chain guesses and silently leaked the
|
// The old approach fell through 4 property-chain guesses and silently leaked the
|
||||||
// player when all of them were undefined (e.g. after a partial cache eviction).
|
// player when all of them were undefined (e.g. after a partial cache eviction).
|
||||||
for (const [channelId, player] of this.players.playerMap) {
|
for (const [channelId, player] of this.players.playerMap) {
|
||||||
@@ -1102,7 +1099,7 @@ export class Remix {
|
|||||||
// wrong decisions. The player's own _channelId is updated inside
|
// wrong decisions. The player's own _channelId is updated inside
|
||||||
// join(), but the map key has to be manually migrated here.
|
// join(), but the map key has to be manually migrated here.
|
||||||
const existingPlayer = this.players.playerMap.get(cleanOld);
|
const existingPlayer = this.players.playerMap.get(cleanOld);
|
||||||
const targetChannel = this.client.channels.cache.get(cleanId)
|
const targetChannel = this.client.channels.get(cleanId)
|
||||||
?? this.client.channels.get?.(cleanId)
|
?? this.client.channels.get?.(cleanId)
|
||||||
?? null;
|
?? null;
|
||||||
const targetGuildId = String(targetChannel?.guildId ?? targetChannel?.guild?.id ?? guildId ?? "").replace(/\D/g, "");
|
const targetGuildId = String(targetChannel?.guildId ?? targetChannel?.guild?.id ?? guildId ?? "").replace(/\D/g, "");
|
||||||
@@ -1282,8 +1279,8 @@ export class Remix {
|
|||||||
|
|
||||||
const cleanGuildId = String(guildId).replace(/\D/g, "");
|
const cleanGuildId = String(guildId).replace(/\D/g, "");
|
||||||
const channelGuildId = String(
|
const channelGuildId = String(
|
||||||
this.client?.channels?.cache?.get?.(channelId)?.guildId ??
|
this.client?.channels?.get?.(channelId)?.guildId ??
|
||||||
this.client?.channels?.cache?.get?.(channelId)?.guild_id ??
|
this.client?.channels?.get?.(channelId)?.guild_id ??
|
||||||
""
|
""
|
||||||
).replace(/\D/g, "");
|
).replace(/\D/g, "");
|
||||||
if (channelGuildId && channelGuildId !== cleanGuildId) {
|
if (channelGuildId && channelGuildId !== cleanGuildId) {
|
||||||
@@ -1392,9 +1389,9 @@ export class Remix {
|
|||||||
if (memberVoice) return seed(memberVoice);
|
if (memberVoice) return seed(memberVoice);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const guild = client.guilds.cache.get(guildId) ?? client.guilds.cache.get(cleanGuild);
|
const guild = client.guilds.get(guildId) ?? client.guilds.get(cleanGuild);
|
||||||
logger.voice(`[checkVC] guild=${guild?.id ?? guild?._id ?? "null"}`);
|
logger.voice(`[checkVC] guild=${guild?.id ?? guild?._id ?? "null"}`);
|
||||||
const voiceStates = guild?.voice_states ?? guild?.voiceStates?.cache ?? guild?.voiceStates ?? null;
|
const voiceStates = guild?.voice_states ?? guild?.voiceStates ?? null;
|
||||||
logger.voice(`[checkVC] voiceStates=${Array.isArray(voiceStates) ? "array["+voiceStates.length+"]" : typeof voiceStates}`);
|
logger.voice(`[checkVC] voiceStates=${Array.isArray(voiceStates) ? "array["+voiceStates.length+"]" : typeof voiceStates}`);
|
||||||
if (voiceStates) {
|
if (voiceStates) {
|
||||||
// Strategy A: direct key lookup — Fluxer may store as { [userId]: channelId }
|
// Strategy A: direct key lookup — Fluxer may store as { [userId]: channelId }
|
||||||
@@ -1527,7 +1524,7 @@ export class Remix {
|
|||||||
// guild.members.cache.has() only works for cached members (requires privileged intents).
|
// guild.members.cache.has() only works for cached members (requires privileged intents).
|
||||||
// Instead, use the settings guilds map — any guild the bot is in and has settings for
|
// Instead, use the settings guilds map — any guild the bot is in and has settings for
|
||||||
// is one we actually serve, which is a reliable proxy for "shared server".
|
// is one we actually serve, which is a reliable proxy for "shared server".
|
||||||
const mutualGuilds = this.client.guilds.cache.filter(g =>
|
const mutualGuilds = this.client.guilds.filter(g =>
|
||||||
this.settingsMgr.guilds.has(g.id)
|
this.settingsMgr.guilds.has(g.id)
|
||||||
);
|
);
|
||||||
return Promise.resolve([...mutualGuilds.values()].map(guild => ({
|
return Promise.resolve([...mutualGuilds.values()].map(guild => ({
|
||||||
@@ -1536,7 +1533,7 @@ export class Remix {
|
|||||||
icon: guild.icon
|
icon: guild.icon
|
||||||
? `https://cdn.fluxer.app/icons/${guild.id}/${guild.icon}.webp`
|
? `https://cdn.fluxer.app/icons/${guild.id}/${guild.icon}.webp`
|
||||||
: null,
|
: null,
|
||||||
voiceChannels: guild.channels.cache
|
voiceChannels: guild.channels
|
||||||
.filter(c => c.isVoiceBased())
|
.filter(c => c.isVoiceBased())
|
||||||
.map(c => ({ name: c.name, id: c.id, icon: null })),
|
.map(c => ({ name: c.name, id: c.id, icon: null })),
|
||||||
})));
|
})));
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export class Option {
|
|||||||
return this.userRegex.test(i) || this.idRegex.test(i);
|
return this.userRegex.test(i) || this.idRegex.test(i);
|
||||||
case "channel":
|
case "channel":
|
||||||
if (i === undefined) return false;
|
if (i === undefined) return false;
|
||||||
return this.channelRegex.test(i) || this.idRegex.test(i) || client.channels.cache.some(c => c.name === i);
|
return this.channelRegex.test(i) || this.idRegex.test(i) || client.channels.some(c => c.name === i);
|
||||||
case "voiceChannel": {
|
case "voiceChannel": {
|
||||||
if (!i) return false;
|
if (!i) return false;
|
||||||
const results = this.channelRegex.exec(i) ?? this.idRegex.exec(i);
|
const results = this.channelRegex.exec(i) ?? this.idRegex.exec(i);
|
||||||
@@ -145,9 +145,9 @@ export class Option {
|
|||||||
if (guildId === "eval") return (results) ? results.groups["id"] : i;
|
if (guildId === "eval") return (results) ? results.groups["id"] : i;
|
||||||
|
|
||||||
const voiceTypes = [2, 13]; // GuildVoice and GuildStageVoice
|
const voiceTypes = [2, 13]; // GuildVoice and GuildStageVoice
|
||||||
const byName = msg?.guild?.channels?.cache?.find(c => c.name === i && voiceTypes.includes(c.type));
|
const byName = msg?.guild?.channels?.find(c => c.name === i && voiceTypes.includes(c.type));
|
||||||
const cObj = results
|
const cObj = results
|
||||||
? client.channels.cache.get(results.groups["id"])
|
? client.channels.get(results.groups["id"])
|
||||||
: (byName ?? null);
|
: (byName ?? null);
|
||||||
return cObj ? voiceTypes.includes(cObj.type) : false;
|
return cObj ? voiceTypes.includes(cObj.type) : false;
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ export class Option {
|
|||||||
}
|
}
|
||||||
case "channel": {
|
case "channel": {
|
||||||
const results = this.channelRegex.exec(i) ?? this.idRegex.exec(i);
|
const results = this.channelRegex.exec(i) ?? this.idRegex.exec(i);
|
||||||
const channel = client.channels.cache.find(c => c.name === i);
|
const channel = client.channels.find(c => c.name === i);
|
||||||
return results ? results.groups["id"] : (channel ? channel.id : null);
|
return results ? results.groups["id"] : (channel ? channel.id : null);
|
||||||
}
|
}
|
||||||
case "voiceChannel": {
|
case "voiceChannel": {
|
||||||
@@ -186,7 +186,7 @@ export class Option {
|
|||||||
const guildId = msg?.channel?.guildId ?? msg?.guildId;
|
const guildId = msg?.channel?.guildId ?? msg?.guildId;
|
||||||
if (guildId === "eval") return r ? r.groups["id"] : (i || null);
|
if (guildId === "eval") return r ? r.groups["id"] : (i || null);
|
||||||
const voiceTypes = [2, 13];
|
const voiceTypes = [2, 13];
|
||||||
const c = msg?.guild?.channels?.cache?.find(c => c.name === i && voiceTypes.includes(c.type));
|
const c = msg?.guild?.channels?.find(c => c.name === i && voiceTypes.includes(c.type));
|
||||||
return r ? r.groups["id"] : (c ? c.id : null);
|
return r ? r.groups["id"] : (c ? c.id : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,7 @@ export class CommandHandler extends EventEmitter {
|
|||||||
this.helpHandler = new HelpHandler(this);
|
this.helpHandler = new HelpHandler(this);
|
||||||
this.helpCommand = "help";
|
this.helpCommand = "help";
|
||||||
this.replyHandler = (message, msg) => {
|
this.replyHandler = (message, msg) => {
|
||||||
msg.replyEmbed(this.format(message, msg.channel.channel.guildId));
|
msg.reply(this.format(message, msg.channel.channel.guildId));
|
||||||
};
|
};
|
||||||
this.messages.onMessage(this.messageHandler.bind(this));
|
this.messages.onMessage(this.messageHandler.bind(this));
|
||||||
}
|
}
|
||||||
@@ -720,13 +720,13 @@ export class CommandLoader {
|
|||||||
result.catch(e => {
|
result.catch(e => {
|
||||||
const id = Utils.uid();
|
const id = Utils.uid();
|
||||||
logger.error("Error running command; error id #" + id, e);
|
logger.error("Error running command; error id #" + id, e);
|
||||||
data.message.replyEmbed("An error occurred. Error id: `#" + id + "`");
|
data.message.reply("An error occurred. Error id: `#" + id + "`");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const id = Utils.uid();
|
const id = Utils.uid();
|
||||||
logger.error("Error running command; error id #" + id, e);
|
logger.error("Error running command; error id #" + id, e);
|
||||||
data.message.replyEmbed("An error occurred. Error id: `#" + id + "`");
|
data.message.reply("An error occurred. Error id: `#" + id + "`");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-11
@@ -133,8 +133,8 @@ export class MessageHandler {
|
|||||||
get(id) {
|
get(id) {
|
||||||
// channel.messages is a MessageManager — @fluxerjs/core may not expose it.
|
// channel.messages is a MessageManager — @fluxerjs/core may not expose it.
|
||||||
// Guard with optional chaining so the loop is a no-op if the property is absent.
|
// Guard with optional chaining so the loop is a no-op if the property is absent.
|
||||||
for (const channel of this.client.channels.cache.values()) {
|
for (const channel of this.client.channels.values()) {
|
||||||
const msg = channel.messages?.cache?.get?.(id) ?? null;
|
const msg = channel.messages?.get?.(id) ?? null;
|
||||||
if (msg) return new Message(msg, this);
|
if (msg) return new Message(msg, this);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -164,7 +164,7 @@ export class MessageHandler {
|
|||||||
* @returns {Channel}
|
* @returns {Channel}
|
||||||
*/
|
*/
|
||||||
getChannel(id) {
|
getChannel(id) {
|
||||||
const c = this.client.channels.cache.get(id);
|
const c = this.client.channels.get(id);
|
||||||
return new Channel(c, this);
|
return new Channel(c, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ export class MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toJSON();
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
#createEmbed(text, message, options = {}) {
|
#createEmbed(text, message, options = {}) {
|
||||||
@@ -384,7 +384,7 @@ export class MessageHandler {
|
|||||||
const currPage = { n: 0 };
|
const currPage = { n: 0 };
|
||||||
const send = () => builder.getPage(currPage.n);
|
const send = () => builder.getPage(currPage.n);
|
||||||
|
|
||||||
const m = await msg.replyEmbed(send());
|
const m = await msg.reply(send());
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
|
|
||||||
m.message.react(arrows[0]).catch(() => {});
|
m.message.react(arrows[0]).catch(() => {});
|
||||||
@@ -396,13 +396,13 @@ export class MessageHandler {
|
|||||||
} else {
|
} else {
|
||||||
currPage.n = Math.min(pages.length - 1, currPage.n + 1);
|
currPage.n = Math.min(pages.length - 1, currPage.n + 1);
|
||||||
}
|
}
|
||||||
m.editEmbed(send()).catch(() => {});
|
m.edit(send()).catch(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto-close after 5 minutes
|
// Auto-close after 5 minutes
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
unobserve();
|
unobserve();
|
||||||
m.editEmbed(send() + "\nSession closed - Changing pages **won't work** from here.").catch(() => {});
|
m.edit(send() + "\nSession closed - Changing pages **won't work** from here.").catch(() => {});
|
||||||
}, 5 * 60 * 1000);
|
}, 5 * 60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,6 +482,14 @@ export class Channel {
|
|||||||
return this.handler.sendMessage(this.channel, content);
|
return this.handler.sendMessage(this.channel, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string|Object} content
|
||||||
|
* @returns {Promise<Message>}
|
||||||
|
*/
|
||||||
|
send(content) {
|
||||||
|
return this.handler.sendMessage(this.channel, content);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string|Object} content
|
* @param {string|Object} content
|
||||||
* @param {Object} embedOptions
|
* @param {Object} embedOptions
|
||||||
@@ -582,6 +590,15 @@ export class Message {
|
|||||||
editEmbed(content, embedOptions = {}) {
|
editEmbed(content, embedOptions = {}) {
|
||||||
return this.handler.editEmbed(this.message, content, embedOptions);
|
return this.handler.editEmbed(this.message, content, embedOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string|Object} content
|
||||||
|
* @param {Object} embedOptions
|
||||||
|
* @returns {Promise<Message>}
|
||||||
|
*/
|
||||||
|
edit(content, embedOptions = {}) {
|
||||||
|
return this.handler.editEmbed(this.message, content, embedOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PageBuilder {
|
export class PageBuilder {
|
||||||
@@ -731,8 +748,7 @@ export class RichPaginator {
|
|||||||
.setAuthor({ name: tab.header })
|
.setAuthor({ name: tab.header })
|
||||||
.setTitle(tab.title)
|
.setTitle(tab.title)
|
||||||
.setDescription(content)
|
.setDescription(content)
|
||||||
.setFooter({ text: footerParts.join(" ") })
|
.setFooter({ text: footerParts.join(" ") });
|
||||||
.toJSON();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async send() {
|
async send() {
|
||||||
@@ -1142,13 +1158,13 @@ export class HelpCommand {
|
|||||||
c.aliases.some(a => a.toLowerCase() === word.toLowerCase())
|
c.aliases.some(a => a.toLowerCase() === word.toLowerCase())
|
||||||
);
|
);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
msg.replyEmbed(`❌ Unknown command \`${word}\`. Use \`${prefix}help\` to browse.`);
|
msg.reply(`❌ Unknown command \`${word}\`. Use \`${prefix}help\` to browse.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currCmd = found;
|
currCmd = found;
|
||||||
}
|
}
|
||||||
if (currCmd) {
|
if (currCmd) {
|
||||||
msg.replyEmbed(this._commands.helpHandler.getCommandHelp(currCmd, msg));
|
msg.reply(this._commands.helpHandler.getCommandHelp(currCmd, msg));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-10
@@ -23,7 +23,7 @@ import { PROVIDER_NAMES } from "./constants/providers.mjs";
|
|||||||
|
|
||||||
/** Emit a plain embed payload so listeners can send it directly */
|
/** Emit a plain embed payload so listeners can send it directly */
|
||||||
function mkEmbed(desc) {
|
function mkEmbed(desc) {
|
||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).toJSON()] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** NodeLink default password — centralised so it doesn't need to be hardcoded in two places. */
|
/** NodeLink default password — centralised so it doesn't need to be hardcoded in two places. */
|
||||||
@@ -593,15 +593,38 @@ export default class Player extends EventEmitter {
|
|||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
try {
|
try {
|
||||||
const channel = this.client?.channels?.cache?.get(this._channelId);
|
// @fluxerjs channels do NOT have a .members property.
|
||||||
const members = channel?.members;
|
// Use the guild's member manager and filter by voice state instead.
|
||||||
if (members) {
|
const guild = this.client?.guilds?.get?.(this._guildId);
|
||||||
const iter = typeof members.values === "function" ? members.values() : Object.values(members);
|
if (guild?.members) {
|
||||||
for (const entry of iter) {
|
for (const member of guild.members.values()) {
|
||||||
const isBot = entry?.user?.bot ?? entry?.member?.user?.bot ?? false;
|
// GuildMember doesn't expose voice channelId directly in @fluxerjs,
|
||||||
|
// so fall through to the voice_states raw data check below.
|
||||||
|
if (!member?.user?.bot) {
|
||||||
|
// We can't determine channel from member alone — skip here
|
||||||
|
// and rely on _observedVoiceUsers or voice_states instead.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fallback: iterate raw voice_states on the guild object.
|
||||||
|
const voiceStates = guild?.voice_states;
|
||||||
|
if (voiceStates) {
|
||||||
|
const entries = Array.isArray(voiceStates)
|
||||||
|
? voiceStates
|
||||||
|
: typeof voiceStates.values === "function"
|
||||||
|
? voiceStates.values()
|
||||||
|
: Object.values(voiceStates);
|
||||||
|
for (const state of entries) {
|
||||||
|
const stateChannelId = String(state?.channelId ?? state?.channel_id ?? "").replace(/\D/g, "");
|
||||||
|
if (stateChannelId === cleanChan) {
|
||||||
|
const userId = String(state?.userId ?? state?.user_id ?? "");
|
||||||
|
// Check if user is a bot — look up via members or observedVoiceUsers
|
||||||
|
const member = guild?.members?.get?.(userId);
|
||||||
|
const isBot = member?.user?.bot ?? false;
|
||||||
if (!isBot) return true;
|
if (!isBot) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -724,7 +747,7 @@ export default class Player extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setupMediaPlayerMonitoring() {
|
_setupMediaPlayerMonitoring() {
|
||||||
// No-op: recovery is fully handled by connection.on("disconnected") in join().
|
// No-op: recovery is fully handled by connection.on("disconnect") in join().
|
||||||
}
|
}
|
||||||
|
|
||||||
async _cleanupMediaPlayer() {
|
async _cleanupMediaPlayer() {
|
||||||
@@ -1066,7 +1089,7 @@ export default class Player extends EventEmitter {
|
|||||||
|
|
||||||
this._isJoining = true;
|
this._isJoining = true;
|
||||||
try {
|
try {
|
||||||
const channel = this.client?.channels?.cache?.get(channelId);
|
const channel = this.client?.channels?.get?.(channelId);
|
||||||
if (!channel) throw new Error(`Channel not found: ${channelId}`);
|
if (!channel) throw new Error(`Channel not found: ${channelId}`);
|
||||||
|
|
||||||
if (this.connection) {
|
if (this.connection) {
|
||||||
@@ -1161,7 +1184,11 @@ export default class Player extends EventEmitter {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on("disconnected", () => {
|
// @fluxerjs VoiceConnection / LiveKitRtcConnection emits "disconnect",
|
||||||
|
// NOT "disconnected" (Discord.js naming). Using the wrong event name meant
|
||||||
|
// this handler was silently never registered — voice disconnect recovery
|
||||||
|
// was completely broken.
|
||||||
|
connection.on("disconnect", () => {
|
||||||
if (this.connection !== connection) {
|
if (this.connection !== connection) {
|
||||||
try { connection.removeAllListeners(); connection.destroy(); } catch (_) {}
|
try { connection.removeAllListeners(); connection.destroy(); } catch (_) {}
|
||||||
return;
|
return;
|
||||||
|
|||||||
+43
-36
@@ -17,7 +17,7 @@ import { getGlobalColor } from "./MessageHandler.mjs";
|
|||||||
|
|
||||||
/** Helper — build a plain embed payload from a description string */
|
/** Helper — build a plain embed payload from a description string */
|
||||||
function mkEmbed(desc) {
|
function mkEmbed(desc) {
|
||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc).toJSON()] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanId(value) {
|
function cleanId(value) {
|
||||||
@@ -123,10 +123,22 @@ export class PlayerManager {
|
|||||||
const sendUserUpdates = (event) => {
|
const sendUserUpdates = (event) => {
|
||||||
if (!this.dashboard?.enabled) return;
|
if (!this.dashboard?.enabled) return;
|
||||||
const channelId = getPlayerChannelId(player, context.channelId);
|
const channelId = getPlayerChannelId(player, context.channelId);
|
||||||
const channel = player.client?.channels?.cache?.get(channelId);
|
const channel = player.client?.channels?.get(channelId);
|
||||||
if (!channel?.members) return;
|
const guild = player.client?.guilds?.get(cleanId(player._guildId ?? context.guildId));
|
||||||
for (const member of channel.members.values()) {
|
if (!guild) return;
|
||||||
if (member.user?.bot) continue;
|
const voiceStates = guild.voice_states ?? guild.voiceStates ?? null;
|
||||||
|
if (!voiceStates) return;
|
||||||
|
const entries = Array.isArray(voiceStates)
|
||||||
|
? voiceStates
|
||||||
|
: typeof voiceStates.values === "function"
|
||||||
|
? [...voiceStates.values()]
|
||||||
|
: Object.values(voiceStates);
|
||||||
|
for (const state of entries) {
|
||||||
|
if (!state?.channelId && !state?.channel_id) continue;
|
||||||
|
const stateChannelId = cleanId(state.channelId ?? state.channel_id);
|
||||||
|
if (stateChannelId !== channelId) continue;
|
||||||
|
const member = guild.members?.get?.(state.userId ?? state.user_id);
|
||||||
|
if (!member?.user || member.user?.bot) continue;
|
||||||
const details = {
|
const details = {
|
||||||
event,
|
event,
|
||||||
guildId: cleanId(player._guildId ?? context.guildId),
|
guildId: cleanId(player._guildId ?? context.guildId),
|
||||||
@@ -249,9 +261,9 @@ export class PlayerManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const guild =
|
const guild =
|
||||||
this.commands.client?.guilds?.cache?.get?.(guildId) ??
|
this.commands.client?.guilds?.get?.(guildId) ??
|
||||||
this.commands.client?.guilds?.cache?.get?.(cleanGuild);
|
this.commands.client?.guilds?.get?.(cleanGuild);
|
||||||
const voiceStates = guild?.voice_states ?? guild?.voiceStates?.cache ?? guild?.voiceStates ?? null;
|
const voiceStates = guild?.voice_states ?? guild?.voiceStates ?? null;
|
||||||
if (voiceStates) {
|
if (voiceStates) {
|
||||||
if (!Array.isArray(voiceStates) && typeof voiceStates === "object") {
|
if (!Array.isArray(voiceStates) && typeof voiceStates === "object") {
|
||||||
const direct = voiceStates[userId];
|
const direct = voiceStates[userId];
|
||||||
@@ -282,7 +294,6 @@ export class PlayerManager {
|
|||||||
const liveGuildPlayers = [...this.playerMap.entries()].filter(([channelId, player]) => {
|
const liveGuildPlayers = [...this.playerMap.entries()].filter(([channelId, player]) => {
|
||||||
const fallbackChannel =
|
const fallbackChannel =
|
||||||
this.commands.client?.channels?.get?.(channelId) ??
|
this.commands.client?.channels?.get?.(channelId) ??
|
||||||
this.commands.client?.channels?.cache?.get?.(channelId) ??
|
|
||||||
null;
|
null;
|
||||||
return getPlayerGuildId(player, fallbackChannel) === cleanGuild;
|
return getPlayerGuildId(player, fallbackChannel) === cleanGuild;
|
||||||
});
|
});
|
||||||
@@ -339,7 +350,7 @@ export class PlayerManager {
|
|||||||
first[1].textChannel = message.channel;
|
first[1].textChannel = message.channel;
|
||||||
return first[1];
|
return first[1];
|
||||||
}
|
}
|
||||||
message.replyEmbed(mkEmbed(`⚠️ You need to join a voice channel to use this command.`));
|
message.reply(mkEmbed(`⚠️ You need to join a voice channel to use this command.`));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +374,7 @@ export class PlayerManager {
|
|||||||
return this.settings.getServer(guildId)?.get("prefix") ?? "%";
|
return this.settings.getServer(guildId)?.get("prefix") ?? "%";
|
||||||
} catch (_) { return "%"; }
|
} catch (_) { return "%"; }
|
||||||
})();
|
})();
|
||||||
message.replyEmbed(mkEmbed(`⚠️ I'm already playing in ${channelList}. Join that channel or use \`${prefix}play\` to start music in your channel.`));
|
message.reply(mkEmbed(`⚠️ I'm already playing in ${channelList}. Join that channel or use \`${prefix}play\` to start music in your channel.`));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +383,7 @@ export class PlayerManager {
|
|||||||
// Auto-detect failed — fall back to interactive channel selection prompt
|
// Auto-detect failed — fall back to interactive channel selection prompt
|
||||||
return this.promptVC(message);
|
return this.promptVC(message);
|
||||||
}
|
}
|
||||||
message.replyEmbed(mkEmbed("⚠️ Please join a voice channel first."));
|
message.reply(mkEmbed("⚠️ Please join a voice channel first."));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,11 +414,10 @@ export class PlayerManager {
|
|||||||
const guildId = getMessageGuildId(msg);
|
const guildId = getMessageGuildId(msg);
|
||||||
const cleanGuildId = cleanId(guildId);
|
const cleanGuildId = cleanId(guildId);
|
||||||
const allChannels = cleanGuildId
|
const allChannels = cleanGuildId
|
||||||
? [...(this.commands.client?.channels?.values?.() ??
|
? [...(this.commands.client?.channels?.values?.() ?? [])]
|
||||||
this.commands.client?.channels?.cache?.values?.() ?? [])]
|
|
||||||
.filter(c => {
|
.filter(c => {
|
||||||
const channelGuildId = cleanId(c.guildId ?? c.guild?.id ?? c.server_id ?? c.serverId);
|
const channelGuildId = cleanId(c.guildId ?? c.guild?.id ?? c.server_id ?? c.serverId);
|
||||||
const isVoice = c.channel_type === "VoiceChannel" || c.type === "VoiceChannel" || c.type === 2;
|
const isVoice = c.type === 2;
|
||||||
return channelGuildId === cleanGuildId && isVoice;
|
return channelGuildId === cleanGuildId && isVoice;
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
@@ -421,7 +431,7 @@ export class PlayerManager {
|
|||||||
channelArr.forEach((c, i) => { channelSelection += `${i + 1}. <#${c._id ?? c.id}>\n`; });
|
channelArr.forEach((c, i) => { channelSelection += `${i + 1}. <#${c._id ?? c.id}>\n`; });
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectionMsg = await msg.replyEmbed(mkEmbed(
|
const selectionMsg = await msg.reply(mkEmbed(
|
||||||
(channelSelection ? channelSelection + "\n**..or**" : "Please") +
|
(channelSelection ? channelSelection + "\n**..or**" : "Please") +
|
||||||
" send a message with the voice channel! (Mention/Id/Name)\nSend 'x' to cancel."
|
" send a message with the voice channel! (Mention/Id/Name)\nSend 'x' to cancel."
|
||||||
));
|
));
|
||||||
@@ -437,7 +447,7 @@ export class PlayerManager {
|
|||||||
|
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
cleanup();
|
cleanup();
|
||||||
msg.replyEmbed(mkEmbed("⏱️ Voice selection timed out."));
|
msg.reply(mkEmbed("⏱️ Voice selection timed out."));
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}, 30_000);
|
}, 30_000);
|
||||||
|
|
||||||
@@ -462,12 +472,12 @@ export class PlayerManager {
|
|||||||
if (content === "x") {
|
if (content === "x") {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
cleanup();
|
cleanup();
|
||||||
m.replyEmbed(mkEmbed("Cancelled!"));
|
m.reply(mkEmbed("Cancelled!"));
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.commands.validateInput("voiceChannel", m.content, m)) {
|
if (!this.commands.validateInput("voiceChannel", m.content, m)) {
|
||||||
m.replyEmbed(mkEmbed("Invalid voice channel. Try again or type `x`."));
|
m.reply(mkEmbed("Invalid voice channel. Try again or type `x`."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const channel = this.commands.formatInput("voiceChannel", m.content, m);
|
const channel = this.commands.formatInput("voiceChannel", m.content, m);
|
||||||
@@ -500,12 +510,12 @@ export class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const player = cid ? this.playerMap.get(cid) : null;
|
const player = cid ? this.playerMap.get(cid) : null;
|
||||||
if (!player) return msg.replyEmbed(mkEmbed("I'm not in a voice channel."));
|
if (!player) return msg.reply(mkEmbed("I'm not in a voice channel."));
|
||||||
|
|
||||||
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
|
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||||
this.playerMap.delete(activeChannelId);
|
this.playerMap.delete(activeChannelId);
|
||||||
if (activeChannelId !== cid) this.playerMap.delete(cid);
|
if (activeChannelId !== cid) this.playerMap.delete(cid);
|
||||||
await msg.replyEmbed(mkEmbed("✅ Successfully Left"));
|
await msg.reply(mkEmbed("✅ Successfully Left"));
|
||||||
await player.leave();
|
await player.leave();
|
||||||
player.destroy();
|
player.destroy();
|
||||||
}
|
}
|
||||||
@@ -521,21 +531,18 @@ export class PlayerManager {
|
|||||||
* @param {Function} [cb]
|
* @param {Function} [cb]
|
||||||
*/
|
*/
|
||||||
initPlayer(message, cid, cb = () => {}) {
|
initPlayer(message, cid, cb = () => {}) {
|
||||||
const channel = this.commands.client?.channels?.get(cid) ??
|
const channel = this.commands.client?.channels?.get(cid);
|
||||||
this.commands.client?.channels?.cache?.get(cid);
|
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return message.replyEmbed(mkEmbed(
|
return message.reply(mkEmbed(
|
||||||
`Couldn't find the channel \`${cid}\`\nUse the help command to learn more about this.`
|
`Couldn't find the channel \`${cid}\`\nUse the help command to learn more about this.`
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const isVoice = channel.channel_type === "VoiceChannel" ||
|
const isVoice = channel.type === 2;
|
||||||
channel.type === "VoiceChannel" ||
|
|
||||||
channel.type === 2;
|
|
||||||
|
|
||||||
if (!isVoice) {
|
if (!isVoice) {
|
||||||
return message.replyEmbed(mkEmbed("❌ Please join a **voice channel** first before using this command!"));
|
return message.reply(mkEmbed("❌ Please join a **voice channel** first before using this command!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanChannelId = cleanId(cid);
|
const cleanChannelId = cleanId(cid);
|
||||||
@@ -544,7 +551,7 @@ export class PlayerManager {
|
|||||||
if (existing) {
|
if (existing) {
|
||||||
existing.textChannel = message.channel;
|
existing.textChannel = message.channel;
|
||||||
cb(existing);
|
cb(existing);
|
||||||
return message.replyEmbed(mkEmbed(`Already joined <#${cid}>.`));
|
return message.reply(mkEmbed(`Already joined <#${cid}>.`));
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = new Player(this.config.token, {
|
const player = new Player(this.config.token, {
|
||||||
@@ -582,7 +589,7 @@ export class PlayerManager {
|
|||||||
const desc = is247
|
const desc = is247
|
||||||
? `Left channel <#${activeChannelId}> because of inactivity.`
|
? `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\``;
|
: `Left channel <#${activeChannelId}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
||||||
ch?.sendEmbed(mkEmbed(desc));
|
ch?.send(mkEmbed(desc));
|
||||||
this.playerMap.delete(activeChannelId);
|
this.playerMap.delete(activeChannelId);
|
||||||
if (activeChannelId !== cleanChannelId) this.playerMap.delete(cleanChannelId);
|
if (activeChannelId !== cleanChannelId) this.playerMap.delete(cleanChannelId);
|
||||||
if (homeChannelId !== activeChannelId) this.playerMap.delete(homeChannelId);
|
if (homeChannelId !== activeChannelId) this.playerMap.delete(homeChannelId);
|
||||||
@@ -598,16 +605,16 @@ export class PlayerManager {
|
|||||||
const disabled = raw === false || raw === 0 ||
|
const disabled = raw === false || raw === 0 ||
|
||||||
["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim());
|
["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim());
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
ch?.sendEmbed(typeof m === "object" && Array.isArray(m.embeds) ? m : mkEmbed(m));
|
ch?.send(typeof m === "object" && Array.isArray(m.embeds) ? m : mkEmbed(m));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.playerMap.set(cleanChannelId, player);
|
this.playerMap.set(cleanChannelId, player);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const statusMsg = await message.replyEmbed(mkEmbed("⏳ Joining Channel..."));
|
const statusMsg = await message.reply(mkEmbed("⏳ Joining Channel..."));
|
||||||
try {
|
try {
|
||||||
await player.join(cid);
|
await player.join(cid);
|
||||||
await statusMsg.editEmbed(mkEmbed(`✅ Successfully joined <#${cid}>`));
|
await statusMsg.edit(mkEmbed(`✅ Successfully joined <#${cid}>`));
|
||||||
|
|
||||||
const guildId = cleanId(channel.guildId ?? getMessageGuildId(message));
|
const guildId = cleanId(channel.guildId ?? getMessageGuildId(message));
|
||||||
if (guildId) {
|
if (guildId) {
|
||||||
@@ -620,7 +627,7 @@ export class PlayerManager {
|
|||||||
|
|
||||||
cb(player);
|
cb(player);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await statusMsg.editEmbed(mkEmbed(`❌ Failed to join: ${err.message}`)).catch(() => {});
|
await statusMsg.edit(mkEmbed(`❌ Failed to join: ${err.message}`)).catch(() => {});
|
||||||
this.playerMap.delete(cleanChannelId);
|
this.playerMap.delete(cleanChannelId);
|
||||||
player.destroy();
|
player.destroy();
|
||||||
}
|
}
|
||||||
@@ -643,12 +650,12 @@ export class PlayerManager {
|
|||||||
? this.playerMap.get(cleanChannelId) ??
|
? this.playerMap.get(cleanChannelId) ??
|
||||||
[...this.playerMap.values()].find((entry) => getPlayerChannelId(entry) === cleanChannelId)
|
[...this.playerMap.values()].find((entry) => getPlayerChannelId(entry) === cleanChannelId)
|
||||||
: null;
|
: null;
|
||||||
if (!player) return msg.replyEmbed(mkEmbed("I'm not in a voice channel."));
|
if (!player) return msg.reply(mkEmbed("I'm not in a voice channel."));
|
||||||
|
|
||||||
const activeChannelId = getPlayerChannelId(player, cleanChannelId) || cleanChannelId;
|
const activeChannelId = getPlayerChannelId(player, cleanChannelId) || cleanChannelId;
|
||||||
this.playerMap.delete(activeChannelId);
|
this.playerMap.delete(activeChannelId);
|
||||||
if (activeChannelId !== cleanChannelId) this.playerMap.delete(cleanChannelId);
|
if (activeChannelId !== cleanChannelId) this.playerMap.delete(cleanChannelId);
|
||||||
await msg.replyEmbed(mkEmbed("✅ Successfully Left"));
|
await msg.reply(mkEmbed("✅ Successfully Left"));
|
||||||
await player.leave();
|
await player.leave();
|
||||||
player.destroy();
|
player.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-13
@@ -40,13 +40,13 @@ export class Dashboard {
|
|||||||
|
|
||||||
case "server": {
|
case "server": {
|
||||||
try {
|
try {
|
||||||
const guild = this.remix.client.guilds.cache.get(data.key);
|
const guild = this.remix.client.guilds.get(data.key);
|
||||||
if (!guild) return { error: "Server not found" };
|
if (!guild) return { error: "Server not found" };
|
||||||
const member = await guild.members.fetch(data.accessor).catch(() => null);
|
const member = await guild.members.fetch(data.accessor).catch(() => null);
|
||||||
const server = Dashboard.convertServer(guild);
|
const server = Dashboard.convertServer(guild);
|
||||||
if (member) {
|
if (member) {
|
||||||
server.channels = server.channels.filter(c => {
|
server.channels = server.channels.filter(c => {
|
||||||
const ch = guild.channels.cache.get(c.id);
|
const ch = guild.channels.get(c.id);
|
||||||
return ch ? ch.permissionsFor(member)?.has("ViewChannel") : false;
|
return ch ? ch.permissionsFor(member)?.has("ViewChannel") : false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -216,9 +216,22 @@ export class Dashboard {
|
|||||||
static convertChannel(channel) {
|
static convertChannel(channel) {
|
||||||
const isVoice = channel.isVoiceBased?.() ?? false;
|
const isVoice = channel.isVoiceBased?.() ?? false;
|
||||||
// Collect voice members for voice channels
|
// Collect voice members for voice channels
|
||||||
const voiceParticipants = isVoice
|
let voiceParticipants = [];
|
||||||
? [...(channel.members?.values() ?? [])].map(m => Dashboard.convertUser(m.user))
|
if (isVoice) {
|
||||||
: [];
|
const guild = channel?.guild ?? channel?.client?.guilds?.get(channel?.guildId);
|
||||||
|
if (guild?.voice_states) {
|
||||||
|
const vs = Array.isArray(guild.voice_states) ? guild.voice_states :
|
||||||
|
typeof guild.voice_states.values === "function" ? [...guild.voice_states.values()] : Object.values(guild.voice_states);
|
||||||
|
for (const state of vs) {
|
||||||
|
const scId = String(state?.channelId ?? state?.channel_id ?? "").replace(/\D/g, "");
|
||||||
|
const chId = String(channel?.id ?? "").replace(/\D/g, "");
|
||||||
|
if (scId === chId) {
|
||||||
|
const user = guild.members?.get?.(state?.userId ?? state?.user_id)?.user;
|
||||||
|
if (user && !user.bot) voiceParticipants.push(Dashboard.convertUser(user));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
@@ -237,11 +250,7 @@ export class Dashboard {
|
|||||||
* @param {import("discord.js").Guild} guild
|
* @param {import("discord.js").Guild} guild
|
||||||
*/
|
*/
|
||||||
static convertServer(guild) {
|
static convertServer(guild) {
|
||||||
// Defensively handle guild.channels — @fluxerjs/core may not always
|
const channelStore = guild.channels;
|
||||||
// populate .cache (e.g. during recovery or for partial guild objects),
|
|
||||||
// or guild.channels itself may be a Map/Collection without a .cache
|
|
||||||
// wrapper. Fallback to guild.channels directly if .cache is absent.
|
|
||||||
const channelStore = guild.channels?.cache ?? guild.channels;
|
|
||||||
const channelIds = channelStore && typeof channelStore.keys === "function"
|
const channelIds = channelStore && typeof channelStore.keys === "function"
|
||||||
? [...channelStore.keys()]
|
? [...channelStore.keys()]
|
||||||
: [];
|
: [];
|
||||||
@@ -265,8 +274,8 @@ export class Dashboard {
|
|||||||
*/
|
*/
|
||||||
static convertPlayer(player) {
|
static convertPlayer(player) {
|
||||||
const channelId = player._channelId;
|
const channelId = player._channelId;
|
||||||
const channel = channelId ? player.client?.channels?.cache?.get(channelId) : null;
|
const channel = channelId ? player.client?.channels?.get(channelId) : null;
|
||||||
const guild = channel?.guild ?? (player._guildId ? player.client?.guilds?.cache?.get(player._guildId) : null);
|
const guild = channel?.guild ?? (player._guildId ? player.client?.guilds?.get(player._guildId) : null);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loop: (player.queue.loop ? 1 : 0) + (player.queue.songLoop ? 2 : 0),
|
loop: (player.queue.loop ? 1 : 0) + (player.queue.songLoop ? 2 : 0),
|
||||||
@@ -276,7 +285,23 @@ export class Dashboard {
|
|||||||
current: Dashboard.convertVideo(player.queue.current),
|
current: Dashboard.convertVideo(player.queue.current),
|
||||||
data: (player.queue.data ?? []).map(v => Dashboard.convertVideo(v))
|
data: (player.queue.data ?? []).map(v => Dashboard.convertVideo(v))
|
||||||
},
|
},
|
||||||
users: channel?.members ? [...channel.members.values()].map(m => m.id) : [],
|
users: (() => {
|
||||||
|
if (!channel) return [];
|
||||||
|
const g = channel?.guild ?? channel?.client?.guilds?.get(channel?.guildId);
|
||||||
|
if (!g?.voice_states) return [];
|
||||||
|
const vs = Array.isArray(g.voice_states) ? g.voice_states :
|
||||||
|
typeof g.voice_states.values === "function" ? [...g.voice_states.values()] : Object.values(g.voice_states);
|
||||||
|
const ids = [];
|
||||||
|
for (const state of vs) {
|
||||||
|
const scId = String(state?.channelId ?? state?.channel_id ?? "").replace(/\D/g, "");
|
||||||
|
const chId = String(channel?.id ?? "").replace(/\D/g, "");
|
||||||
|
if (scId === chId) {
|
||||||
|
const memberId = String(state?.userId ?? state?.user_id ?? "");
|
||||||
|
if (memberId) ids.push(memberId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
})(),
|
||||||
channel: channel ? Dashboard.convertChannel(channel) : null,
|
channel: channel ? Dashboard.convertChannel(channel) : null,
|
||||||
server: guild ? Dashboard.convertServer(guild) : null,
|
server: guild ? Dashboard.convertServer(guild) : null,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user