HiddenPhox/src/modules/music.js

807 lines
23 KiB
JavaScript
Raw Normal View History

2023-01-22 04:45:57 +00:00
const {Collection} = require("@projectdysnomia/dysnomia");
2023-09-13 04:51:51 +00:00
const {Readable} = require("node:stream");
const ffprobe = require("node-ffprobe");
const Command = require("../lib/command.js");
2023-01-24 01:22:53 +00:00
const {
formatTime,
parseHtmlEntities,
2023-09-15 03:09:20 +00:00
pomello,
selectionMessage,
2023-01-24 01:22:53 +00:00
} = require("../lib/utils.js");
const REGEX_YOUTUBE = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
const REGEX_YOUTUBE_PLAYLIST =
/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/playlist\?list=(.+)$/;
const REGEX_YOUTUBE_PLAYLIST_SHORT = /^PL[a-zA-Z0-9-_]{1,32}$/;
const REGEX_SOUNDCLOUD =
/^((https?:\/\/)?(www\.|m\.)?soundcloud\.com\/|sc:).+\/.+$/;
const REGEX_SOUNDCLOUD_PLAYLIST =
/^((https?:\/\/)?(www\.|m\.)?soundcloud\.com\/|sc:).+\/(sets\/.+|likes|tracks)$/;
const REGEX_FILE =
/^(https?:\/\/)?.*\..*\/.+\.(mp3|ogg|flac|wav|webm|mp4|mov|mkv|mod|s3m|it|xm)$/;
let SOUNDCLOUD_CLIENTID;
hf.voiceStorage = hf.voiceStorage || new Collection();
const voiceStorage = hf.voiceStorage;
// https://stackoverflow.com/a/12646864 § "Updating to ES6 / ECMAScript 2015"
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
async function getSoundcloudClientID() {
if (SOUNDCLOUD_CLIENTID != null) {
return SOUNDCLOUD_CLIENTID;
}
const page = await fetch("https://soundcloud.com").then((res) => res.text());
const scripts = page
.match(/<script crossorigin src="(.+?)"><\/script>/g)
.reverse();
for (const script of scripts) {
const url = script.match(/src="(.+?)"/)[1];
const contents = await fetch(url).then((res) => res.text());
if (/,client_id:"(.+?)",/.test(contents)) {
const client_id = contents.match(/,client_id:"(.+?)",/)[1];
SOUNDCLOUD_CLIENTID = client_id;
return SOUNDCLOUD_CLIENTID;
}
}
return null;
}
async function processPlaylist(
url,
type,
shuffle = false,
limit = -1,
offset = 0
) {
let playlist;
if (type === "yt") {
const playlistId =
url.match(REGEX_YOUTUBE_PLAYLIST)?.[4] ??
url.match(REGEX_YOUTUBE_PLAYLIST_SHORT)?.[0];
if (!playlistId) return null;
2023-09-13 04:24:17 +00:00
const baseUrl = "/playlists/" + playlistId;
2023-09-13 04:24:17 +00:00
const data = await fetch(hf.config.piped_api + baseUrl).then((res) =>
res.json()
);
2023-09-13 04:24:17 +00:00
playlist = data.relatedStreams;
2023-09-13 04:24:17 +00:00
let pageToken = data.nextpage;
while (pageToken?.startsWith("{")) {
const pageData = await fetch(
hf.config.piped_api +
"/nextpage" +
baseUrl +
"&nextpage=" +
encodeURIComponent(pageToken)
).then((res) => res.json());
if (pageData.nextpage) pageToken = pageData.nextpage;
2023-09-13 04:24:17 +00:00
playlist = [...playlist, ...pageData.relatedStreams];
}
} else if (type === "sc") {
const clientId = await getSoundcloudClientID();
if (url.indexOf("/likes") > -1) {
let userInfo = await fetch(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
).then((res) => res.json());
while (!userInfo.uri) {
userInfo = await fetch(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
).then((res) => res.json());
}
const likesUrl =
userInfo.uri.replace("api.", "api-v2.") +
"/likes?limit=500&client_id=" +
clientId;
let currentLikes = await fetch(likesUrl).then((res) => res.json());
playlist = currentLikes.collection;
while (currentLikes.next_href != null) {
currentLikes = await fetch(
currentLikes.next_href + "&client_id=" + clientId
).then((res) => res.json());
playlist = [...playlist, ...currentLikes.collection];
}
} else {
playlist = await fetch(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
)
.then((res) => res.json())
.then((obj) => obj.tracks);
}
}
if (shuffle === true && playlist != null) {
shuffleArray(playlist);
}
if (offset > 0) {
playlist = playlist.slice(offset);
}
if (limit > 0) {
playlist = playlist.slice(0, limit);
}
return playlist;
}
async function createVoiceConnection(guild_id, voice_id, text_id) {
2022-12-10 22:08:58 +00:00
const state = {
voice_id,
text_id,
};
2023-01-22 05:07:27 +00:00
state.connection = await hf.bot.joinVoiceChannel(voice_id, {
selfDeaf: true,
selfMute: false,
});
state.queue = [];
state.onEnd = async function () {
if (state.queue.length > 0) {
const next = state.queue.splice(0, 1)[0];
2022-08-03 04:00:10 +00:00
await enqueue({
guild_id,
voice_id,
text_id,
2022-08-03 04:00:10 +00:00
url: next.url,
type: next.type,
addedBy: next.addedBy,
});
} else {
2023-01-22 04:45:57 +00:00
await state.connection.disconnect();
if (!state.__leave) {
2022-12-10 22:17:07 +00:00
await hf.bot.guilds.get(guild_id).channels.get(text_id).createMessage({
content: ":musical_note: Queue is empty, leaving voice channel.",
});
2022-12-10 22:08:58 +00:00
await hf.bot.leaveVoiceChannel(voice_id);
}
2023-01-22 04:45:57 +00:00
state.connection.off("end", state.onEnd);
voiceStorage.delete(guild_id);
}
};
2023-01-22 04:45:57 +00:00
state.connection.on("end", state.onEnd);
voiceStorage.set(guild_id, state);
return state;
}
2022-08-03 04:00:10 +00:00
async function enqueue({
guild_id,
voice_id,
text_id,
url,
type,
addedBy,
2022-05-04 21:46:29 +00:00
suppress = false,
2022-08-03 04:00:10 +00:00
queueNext = false,
}) {
if (!url) return;
const connection =
voiceStorage.get(guild_id) ??
(await createVoiceConnection(guild_id, voice_id, text_id));
const textChannel = hf.bot.guilds.get(guild_id).channels.get(text_id);
let title,
length,
thumbnail,
media,
stream = false;
if (type == "yt") {
let info;
let id = url;
try {
2023-04-26 23:16:22 +00:00
if (/^https?:\/\//.test(url)) {
const uri = new URL(url);
if (uri.hostname == "youtu.be") {
id = uri.pathname.substring(1);
} else if (uri.hostname.indexOf("youtube.com") > -1) {
id = uri.searchParams.get("v");
}
}
2023-09-13 04:30:32 +00:00
info = await fetch(`${hf.config.piped_api}/streams/${id}`).then((res) =>
res.json()
);
} catch (err) {
2022-12-10 21:55:39 +00:00
await textChannel.createMessage({
content: `:warning: Failed to get metadata: \`\`\`\n${err}\n\`\`\``,
});
}
2023-09-13 04:33:34 +00:00
title = info?.title;
2023-09-13 04:24:17 +00:00
length = info?.duration * 1000;
thumbnail = info?.thumbnailUrl;
const hlsUrl = new URL(info.hls);
2023-09-13 04:51:51 +00:00
media = Readable.from(
await fetch(info.hls)
.then((res) => res.text())
.then((data) =>
data.replaceAll(
"/api/manifest/",
`https://${hlsUrl.hostname}/api/manifest/`
)
)
2023-09-13 04:51:51 +00:00
);
} else if (type == "sc") {
if (url?.startsWith("sc:"))
url = url.replace(/^sc:/, "https://soundcloud.com/");
const client_id = await getSoundcloudClientID();
const info = await fetch(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${client_id}`
).then((res) => res.json());
const formatUrl = info.media.transcodings.filter(
(obj) => !obj.snipped && obj.format.protocol == "progressive"
)[0].url;
const streamUrl = await fetch(`${formatUrl}?client_id=${client_id}`)
.then((res) => res.json())
.then((obj) => obj.url);
title = info.title;
length = info.duration;
thumbnail = info.artwork_url;
media = streamUrl;
} else if (type == "file") {
title = url;
let info;
try {
info = await ffprobe(url).then((obj) => obj.format);
} catch (err) {
2022-12-10 21:55:39 +00:00
textChannel.createMessage({
content: `:warning: Failed to get metadata: \`\`\`\n${err}\n\`\`\``,
});
}
stream = !info.duration;
if (info.tags) {
title = `${
info.tags.artist ??
info.tags.ARTIST ??
info.tags.album_artist ??
info.tags.ALBUM_ARTIST ??
"<unknown artist>"
} - ${info.tags.title ?? info.tags.TITLE ?? "<no title>"}`;
}
length = info.duration ? Math.floor(info.duration) * 1000 : 0;
media = url;
}
2023-01-22 04:45:57 +00:00
if (connection.connection.playing) {
2022-05-04 21:46:29 +00:00
const queueItem = {
url,
type,
title,
length,
addedBy,
stream,
id: Math.random().toString(16).substring(2),
2022-05-04 21:46:29 +00:00
};
if (queueNext === true) {
connection.queue.splice(0, 0, queueItem);
2022-05-04 21:46:29 +00:00
} else {
connection.queue.push(queueItem);
2022-05-04 21:46:29 +00:00
}
if (suppress === false) {
textChannel.createMessage({
embeds: [
{
2022-05-04 21:46:29 +00:00
title: `<:ms_tick:503341995348066313> Added to queue ${
queueNext === true ? "(next up)" : ""
}`,
2022-04-20 20:51:56 +00:00
color: 0x00cc00,
fields: [
{
name: "Title",
2023-09-13 04:33:34 +00:00
value: (title !== url ? `[${title}](${url})` : url).substring(
0,
1024
),
inline: true,
},
{
name: "Length",
value: stream
? "<continuous>"
: length
? formatTime(length)
: "<unknown>",
inline: true,
},
{
name: "Added by",
value: `<@${addedBy}>`,
inline: true,
},
],
thumbnail: {
url: thumbnail,
},
},
],
});
}
} else {
if (!media) {
2022-12-10 21:55:39 +00:00
textChannel.createMessage({
content: `:warning: No usable media was found for \`${url}\`. May possibly be due to region restrictions or paywalls.`,
});
return;
}
await connection.connection.play(media, {
2023-01-22 04:45:57 +00:00
inlineVolume: true,
voiceDataTimeout: -1,
2023-09-29 03:46:19 +00:00
inputArgs: [
"-protocol_whitelist",
"file,http,https,tcp,tls,pipe,data,crypto",
],
2023-01-22 04:45:57 +00:00
});
textChannel.createMessage({
embeds: [
{
2022-04-19 04:52:48 +00:00
title: `:musical_note: Now Playing`,
2022-04-20 20:51:56 +00:00
color: 0x0088cc,
fields: [
{
name: "Title",
2023-01-24 01:13:11 +00:00
value: (title ? `[${title}](${url})` : url).substring(0, 1024),
inline: true,
},
{
name: "Length",
value: stream
? "<continuous>"
: length
? formatTime(length)
: "<unknown>",
inline: true,
},
{
name: "Added by",
value: `<@${addedBy}>`,
inline: true,
},
],
thumbnail: {
url: thumbnail,
},
},
],
});
2022-12-10 22:08:58 +00:00
connection.nowplaying = {
title,
addedBy,
thumbnail,
length,
start: Date.now(),
stream,
2022-04-20 21:01:34 +00:00
url,
};
}
}
async function youtubeSearch(msg, str) {
2022-04-19 05:16:09 +00:00
const {items} = await fetch(
2023-09-13 04:24:17 +00:00
`${hf.config.piped_api}/search?q=${encodeURIComponent(str)}&filter=videos`
).then((x) => x.json());
const selection = items.map((item) => ({
value: "https://youtube.com" + item.url,
2023-09-13 04:24:17 +00:00
key: item.url.replace("/watch?v=", ""),
display: `${parseHtmlEntities(item.title).substring(0, 99)}${
parseHtmlEntities(item.title).length > 99 ? "…" : ""
}`,
2023-09-13 04:24:17 +00:00
description: `from ${parseHtmlEntities(item.uploaderName).substring(
2023-04-08 20:12:52 +00:00
0,
95
2023-09-13 04:24:17 +00:00
)}${parseHtmlEntities(item.uploaderName).length > 95 ? "…" : ""}`,
}));
try {
return await selectionMessage(msg, "Search results:", selection);
} catch (out) {
return out;
}
}
2022-04-20 20:51:56 +00:00
const NOWPLAYING_BAR_LENGTH = 30;
const command = new Command("music");
command.addAlias("m");
command.category = "misc";
command.helpText = "Music";
command.usage = "help";
command.callback = async function (
msg,
line,
2022-12-10 22:20:19 +00:00
args,
{shuffle = false, limit = -1, offset = 0, next = false}
) {
if (!msg.guildID) return "This command can only be used in guilds.";
2022-12-10 22:20:19 +00:00
const subcommand = args.shift();
let argStr = args.join(" ");
switch (subcommand) {
case "play":
case "p":
if (msg.member?.voiceState?.channelID) {
if (voiceStorage.has(msg.guildID)) {
2022-04-24 18:56:53 +00:00
const connection = voiceStorage.get(msg.guildID);
2022-12-10 22:08:58 +00:00
if (connection.voice_id != msg.member.voiceState.channelID) {
return "You are in a different voice channel than the bot.";
}
}
let type;
let playlist = false;
if (
REGEX_YOUTUBE_PLAYLIST.test(argStr) ||
REGEX_YOUTUBE_PLAYLIST_SHORT.test(argStr)
) {
type = "yt";
playlist = true;
} else if (REGEX_SOUNDCLOUD_PLAYLIST.test(argStr)) {
type = "sc";
playlist = true;
} else if (REGEX_YOUTUBE.test(argStr)) {
type = "yt";
} else if (REGEX_SOUNDCLOUD.test(argStr)) {
type = "sc";
} else if (REGEX_FILE.test(argStr)) {
type = "file";
2023-04-24 17:10:24 +00:00
} else if (msg.attachments.size > 0) {
const entries = [...msg.attachments.values()].filter((attachment) =>
2022-04-19 04:56:30 +00:00
REGEX_FILE.test(attachment.url)
);
if (entries.length > 0) {
type = "file";
argStr = entries[0].url;
}
}
if (type != null) {
if (playlist) {
2022-04-22 02:05:36 +00:00
const statusMessage = await msg.channel.createMessage({
embeds: [
{
title:
"<a:loading:493087964918972426> Processing playlist...",
description: `Fetching tracks...`,
color: 0xcc0088,
},
],
});
const playlist = await processPlaylist(
argStr,
type,
shuffle,
limit,
offset
);
await statusMessage.edit({
embeds: [
{
title:
"<a:loading:493087964918972426> Processing playlist...",
description: `${playlist.length} tracks`,
2022-04-20 20:51:56 +00:00
color: 0xcc0088,
},
],
});
for (const track of playlist) {
let url;
if (type == "yt") {
url = "https://youtube.com" + track.url;
} else if (type == "sc") {
url = track.track
? track.track.permalink_url
: track.permalink_url;
}
2022-08-03 04:00:10 +00:00
await enqueue({
guild_id: msg.guildID,
voice_id: msg.member.voiceState.channelID,
text_id: msg.channel.id,
url,
type,
2022-08-03 04:00:10 +00:00
addedBy: msg.author.id,
suppress: true,
2022-08-03 04:00:10 +00:00
});
}
await statusMessage.edit({
embeds: [
{
title: "<:ms_tick:503341995348066313> Done processing",
description: `${playlist.length} tracks`,
2022-04-20 20:51:56 +00:00
color: 0xcc0088,
},
],
});
} else {
2022-08-03 04:00:10 +00:00
await enqueue({
guild_id: msg.guildID,
voice_id: msg.member.voiceState.channelID,
text_id: msg.channel.id,
url: argStr,
type,
2022-08-03 04:00:10 +00:00
addedBy: msg.author.id,
queueNext: next,
2022-08-03 04:00:10 +00:00
});
}
} else {
2022-12-10 22:20:19 +00:00
if (argStr.match(/^https?:\/\//)) {
const contentType = await fetch(argStr).then((res) =>
res.headers.get("Content-Type")
);
if (
contentType.startsWith("audio/") ||
contentType.startsWith("video/")
) {
2022-08-03 04:00:10 +00:00
await enqueue({
guild_id: msg.guildID,
voice_id: msg.member.voiceState.channelID,
text_id: msg.channel.id,
url: argStr,
type: "file",
addedBy: msg.author.id,
queueNext: next,
2022-08-03 04:00:10 +00:00
});
} else {
return "Unsupported content type.";
}
} else {
const url = await youtubeSearch(msg, argStr);
if (url?.startsWith("https://youtube.com/")) {
2022-08-03 04:00:10 +00:00
await enqueue({
guild_id: msg.guildID,
voice_id: msg.member.voiceState.channelID,
text_id: msg.channel.id,
url,
2022-08-03 04:00:10 +00:00
type: "yt",
addedBy: msg.author.id,
queueNext: next,
2022-08-03 04:00:10 +00:00
});
} else {
return url;
}
}
}
} else {
return "You are not in a voice channel.";
}
break;
case "skip":
case "s":
if (msg.member?.voiceState?.channelID) {
const connection = voiceStorage.get(msg.guildID);
if (voiceStorage.has(msg.guildID)) {
2022-12-10 22:08:58 +00:00
if (connection.voice_id != msg.member.voiceState.channelID) {
return "You are in a different voice channel than the bot.";
}
}
// TODO: skip lock checks
2023-01-24 01:07:17 +00:00
await connection.connection.stopPlaying();
return {reaction: "\u23ed"};
} else {
return "You are not in a voice channel.";
}
case "leave":
case "l":
case "stop":
if (msg.member?.voiceState?.channelID) {
const connection = voiceStorage.get(msg.guildID);
if (voiceStorage.has(msg.guildID)) {
2022-12-10 22:08:58 +00:00
if (connection.voice_id != msg.member.voiceState.channelID) {
return "You are in a different voice channel than the bot.";
}
}
// TODO: skip lock checks
2022-12-10 21:53:53 +00:00
connection.queue = [];
connection.__leave = true;
2023-01-24 01:07:17 +00:00
await connection.connection.stopPlaying();
2022-12-10 22:59:34 +00:00
connection.onEnd();
2022-04-19 05:10:13 +00:00
await hf.bot.leaveVoiceChannel(msg.member.voiceState.channelID);
return {reaction: "\uD83D\uDC4B"};
} else {
return "You are not in a voice channel.";
}
2022-04-20 20:51:56 +00:00
case "np": {
if (!voiceStorage.has(msg.guildID))
return "The bot is not in a voice channel.";
const connection = voiceStorage.get(msg.guildID);
2022-12-10 22:08:58 +00:00
const nowPlaying = connection.nowplaying;
2023-01-22 04:45:57 +00:00
if (!nowPlaying || !connection.connection.playing)
2022-04-20 20:51:56 +00:00
return "Nothing is currently playing.";
const position = Date.now() - nowPlaying.start;
2023-01-22 04:45:57 +00:00
const timeEnd =
nowPlaying.length == 0 ? "\u221e" : formatTime(nowPlaying.length);
2022-04-20 20:51:56 +00:00
const timePos = formatTime(position);
2023-01-22 04:45:57 +00:00
const progress =
nowPlaying.length == 0 ? 1 : position / nowPlaying.length;
2022-04-20 20:51:56 +00:00
const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH);
const bar = `\`[${"=".repeat(barLength)}${" ".repeat(
NOWPLAYING_BAR_LENGTH - barLength
)}]\``;
const time = `\`${timePos}${" ".repeat(
NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length
)}${timeEnd}\``;
return {
embed: {
title: ":musical_note: Now Playing",
color: 0x0088cc,
fields: [
{
name: "Title",
value: nowPlaying.title
? `[${nowPlaying.title}](${nowPlaying.url})`
: nowPlaying.url,
inline: true,
},
{
name: "Added by",
value: `<@${nowPlaying.addedBy}>`,
inline: true,
},
{
name: bar,
value: time,
inline: false,
},
],
},
};
}
case "queue":
2022-04-24 17:34:54 +00:00
case "q": {
if (!voiceStorage.has(msg.guildID))
return "The bot is not in a voice channel";
const connection = voiceStorage.get(msg.guildID);
2022-12-10 22:08:58 +00:00
const queue = connection.queue;
2022-04-24 17:34:54 +00:00
if (queue.length === 0) return "Nothing else is currently queued";
2022-12-10 22:08:58 +00:00
const nowPlaying = connection.nowplaying;
2022-04-24 17:34:54 +00:00
const now = Date.now();
2022-04-24 17:41:19 +00:00
let nextTrack = now + (nowPlaying.length - (now - nowPlaying.start));
2022-04-24 17:34:54 +00:00
const fields = [];
2022-04-24 17:43:21 +00:00
for (const index in queue.slice(0, 9)) {
2022-04-24 17:34:54 +00:00
const item = queue[index];
fields.push({
name: item.title ?? item.url,
value: `${item.title ? `[Link](${item.url}) - ` : ""}${formatTime(
item.length
2022-04-24 17:41:19 +00:00
)}\nAdded by: <@${item.addedBy}>\n<t:${Math.floor(
nextTrack / 1000
)}:R>`,
2022-04-24 17:34:54 +00:00
inline: true,
});
2022-04-24 17:41:19 +00:00
nextTrack += item.length;
2022-04-24 17:34:54 +00:00
}
2022-05-04 21:37:59 +00:00
let totalLength = 0;
for (const item of queue) {
totalLength += item.length;
}
2022-04-24 17:34:54 +00:00
return {
embed: {
2022-04-24 18:56:53 +00:00
title: ":inbox_tray: Currently Queued",
2022-04-24 17:34:54 +00:00
color: 0x0088cc,
fields,
footer: {
2022-05-04 21:37:59 +00:00
text:
(queue.length > 9 ? `Showing 9/${queue.length} items | ` : "") +
`Total length: ${formatTime(totalLength)}`,
2022-04-24 17:34:54 +00:00
},
},
};
}
case "remove":
case "qr":
2022-04-24 18:56:53 +00:00
if (msg.member?.voiceState?.channelID) {
const connection = voiceStorage.get(msg.guildID);
if (voiceStorage.has(msg.guildID)) {
2022-12-10 22:08:58 +00:00
if (connection.voice_id != msg.member.voiceState.channelID) {
2022-04-24 18:56:53 +00:00
return "You are in a different voice channel than the bot.";
}
}
2022-12-10 22:08:58 +00:00
let queue = connection.queue;
2022-04-24 18:56:53 +00:00
if (queue.length === 0) return "Nothing else is currently queued";
const hasManageMessages = msg.member.permissions.has("manageMessages");
if (!hasManageMessages)
queue = queue.filter((item) => item.addedBy == msg.member.id);
if (queue.length === 0) return "You currently have nothing queued";
const toRemove = await selectionMessage(
msg,
"Choose items to remove",
queue.slice(0, 25).map((item) => {
const user = hf.bot.users.get(item.addedBy);
return {
key: item.id,
2022-04-24 18:56:53 +00:00
display: (item.title ?? item.url).substr(0, 100),
2023-01-22 05:09:36 +00:00
description: hasManageMessages
2023-09-15 03:09:20 +00:00
? `Added by: ${pomello(user)}`
2023-01-22 05:09:36 +00:00
: "",
2022-04-24 18:56:53 +00:00
};
}),
30000,
Math.min(queue.length, 25)
2022-04-24 18:56:53 +00:00
);
if (Array.isArray(toRemove)) {
2022-12-10 22:08:58 +00:00
connection.queue = connection.queue.filter(
(item) => !toRemove.includes(item.id)
);
2022-04-24 18:56:53 +00:00
return `Removed ${toRemove.length} item(s).`;
} else {
return toRemove;
}
} else {
return "You are not in a voice channel";
}
case "lock":
case "unlock":
return "TODO";
case "help":
case "h":
return `**__Music Subcommands__**
\u2022 \`play/p [url|search string]\` - Play or add to queue. Supports: YouTube, SoundCloud, mp3/flac/ogg/wav/webm/mp4/mov/mkv/mod/s3m/it/xm, streams
\u2022 \`queue/q (page)\` - Lists the current queue.
\u2022 \`leave/l/stop\` - Leaves the voice channel.
\u2022 \`np\` - Shows whats currently playing.
\u2022 \`skip/s\` - Skips whats currently playing.
\u2022 \`remove/qr\` - Remove an item from queue.
\u2022 \`lock\` - Lock skipping and queue. (manage messages)
\u2022 \`unlock\` - Unlock skipping and queue. (manage messages)
\u2022 \`help/h\` - This text.`;
default:
return `Invalid/missing subcommand. See \`${hf.config.prefix}music help\` for all subcommands.`;
}
return null; // shutting up eslint
};
hf.registerCommand(command);