mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
test: some cool stuff from shadowsss
This commit is contained in:
1 parent
47b1615cbc
commit
910a244120
2 files changed
+62
-12
No files matched your search
+53
-7
@@ -56,8 +56,8 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
|||||||
} catch (_) { return "%"; }
|
} catch (_) { return "%"; }
|
||||||
})();
|
})();
|
||||||
const desc = is247
|
const desc = is247
|
||||||
? `Left channel <#${cid}> because of inactivity.`
|
? `Left channel <#${cid}> because of inactivity.`
|
||||||
: `Left channel <#${cid}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
: `Left channel <#${cid}> 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();
|
.toJSON();
|
||||||
@@ -98,16 +98,62 @@ export const command = new CommandBuilder()
|
|||||||
.setName("join")
|
.setName("join")
|
||||||
.setDescription("Make the bot join your voice channel, or specify one.", "commands.join")
|
.setDescription("Make the bot join your voice channel, or specify one.", "commands.join")
|
||||||
.setId("join")
|
.setId("join")
|
||||||
.setCategory("music");
|
.setCategory("music")
|
||||||
|
.addTextOption(option =>
|
||||||
|
option.setName("channel")
|
||||||
|
.setDescription("A voice channel mention, ID, or name to join. Defaults to your current channel.")
|
||||||
|
.setRequired(false)
|
||||||
|
);
|
||||||
|
|
||||||
export function run(message) {
|
export function run(message, data) {
|
||||||
// @fluxerjs/core Message has no .member property — voice channel detection
|
// Check if a channel argument was provided (mention like <#123456>, bare ID, or name)
|
||||||
// is handled entirely by checkVoiceChannels() via the VoiceManager state map.
|
const rawArg = data?.get?.("channel")?.value?.trim?.() ?? null;
|
||||||
|
|
||||||
|
if (rawArg) {
|
||||||
|
// Parse channel mention <#ID>, bare numeric ID, or channel name
|
||||||
|
const mentionMatch = rawArg.match(/^<#(\d+)>$/);
|
||||||
|
const idMatch = rawArg.match(/^(\d{15,})$/);
|
||||||
|
let resolvedId = null;
|
||||||
|
|
||||||
|
if (mentionMatch) {
|
||||||
|
resolvedId = mentionMatch[1];
|
||||||
|
} else if (idMatch) {
|
||||||
|
resolvedId = idMatch[1];
|
||||||
|
} else {
|
||||||
|
// Try to look up by name
|
||||||
|
const serverId = message.channel?.server_id ?? message.channel?.serverId;
|
||||||
|
const allChannels = [
|
||||||
|
...(this._commands?.client?.channels?.values?.() ??
|
||||||
|
this._commands?.client?.channels?.cache?.values?.() ??
|
||||||
|
this.client?.channels?.values?.() ??
|
||||||
|
this.client?.channels?.cache?.values?.() ?? [])
|
||||||
|
];
|
||||||
|
const match = allChannels.find(c => {
|
||||||
|
const cServerId = c.server_id ?? c.serverId ?? c.guildId;
|
||||||
|
const isVoice = c.channel_type === "VoiceChannel" || c.type === "VoiceChannel" || c.type === 2;
|
||||||
|
return isVoice && cServerId === serverId &&
|
||||||
|
(c.name?.toLowerCase() === rawArg.toLowerCase());
|
||||||
|
});
|
||||||
|
if (match) resolvedId = match._id ?? match.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!resolvedId) {
|
||||||
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
|
.setDescription("❌ Couldn't find that voice channel. Try using a mention like `<#channelid>` or the exact channel name.")
|
||||||
|
.toJSON();
|
||||||
|
return message.replyEmbed({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.players.initPlayer(message, resolvedId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No argument — auto-detect the user's current voice channel
|
||||||
const cid = this.players.checkVoiceChannels(message);
|
const cid = this.players.checkVoiceChannels(message);
|
||||||
|
|
||||||
if (!cid) {
|
if (!cid) {
|
||||||
|
const prefix = this._commands?.getPrefix?.(message.channel?.guild?.id ?? message.channel?.server_id ?? message.channel?.serverId) ?? "%";
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription("❌ You're not in a voice channel. Please join one first.")
|
.setDescription(`❌ You're not in a voice channel. Please join one first, or specify a channel: \`${prefix}join <#channel>\``)
|
||||||
.toJSON();
|
.toJSON();
|
||||||
return message.replyEmbed({ embeds: [embed] });
|
return message.replyEmbed({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ export class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!userChannelId) {
|
if (!userChannelId) {
|
||||||
|
if (shouldJoin) {
|
||||||
|
// Auto-detect failed — fall back to interactive channel selection prompt
|
||||||
|
return this.promptVC(message);
|
||||||
|
}
|
||||||
message.replyEmbed(mkEmbed("⚠️ Please join a voice channel first."));
|
message.replyEmbed(mkEmbed("⚠️ Please join a voice channel first."));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -163,7 +167,7 @@ export class PlayerManager {
|
|||||||
async promptVC(msg) {
|
async promptVC(msg) {
|
||||||
const autoDetected = this.checkVoiceChannels(msg);
|
const autoDetected = this.checkVoiceChannels(msg);
|
||||||
if (autoDetected) {
|
if (autoDetected) {
|
||||||
return new Promise(resolve => this.initPlayer(msg, autoDetected, () => resolve(autoDetected)));
|
return new Promise(resolve => this.initPlayer(msg, autoDetected, (p) => resolve(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverId = msg.channel?.server_id ?? msg.channel?.serverId;
|
const serverId = msg.channel?.server_id ?? msg.channel?.serverId;
|
||||||
@@ -215,7 +219,7 @@ export class PlayerManager {
|
|||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
cleanup();
|
cleanup();
|
||||||
const cid = channel._id ?? channel.id;
|
const cid = channel._id ?? channel.id;
|
||||||
this.initPlayer(msg, cid, () => resolve(cid));
|
this.initPlayer(msg, cid, (p) => resolve(p));
|
||||||
},
|
},
|
||||||
msg.author
|
msg.author
|
||||||
);
|
);
|
||||||
@@ -237,7 +241,7 @@ export class PlayerManager {
|
|||||||
const channel = this.commands.formatInput("voiceChannel", m.content, m);
|
const channel = this.commands.formatInput("voiceChannel", m.content, m);
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
cleanup();
|
cleanup();
|
||||||
this.initPlayer(m, channel, () => resolve(channel));
|
this.initPlayer(m, channel, (p) => resolve(p));
|
||||||
}, msg.author);
|
}, msg.author);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -335,8 +339,8 @@ export class PlayerManager {
|
|||||||
} catch (_) { return "%"; }
|
} catch (_) { return "%"; }
|
||||||
})();
|
})();
|
||||||
const desc = is247
|
const desc = is247
|
||||||
? `Left channel <#${cid}> because of inactivity.`
|
? `Left channel <#${cid}> because of inactivity.`
|
||||||
: `Left channel <#${cid}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
: `Left channel <#${cid}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
||||||
ch?.sendEmbed(mkEmbed(desc));
|
ch?.sendEmbed(mkEmbed(desc));
|
||||||
this.playerMap.delete(cid);
|
this.playerMap.delete(cid);
|
||||||
player.destroy();
|
player.destroy();
|
||||||
|
|||||||
Reference in new issue
Block a user