diff --git a/src/lib/utils.js b/src/lib/utils.js index f510204..f1df767 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -372,14 +372,12 @@ const htmlEntities = { function parseHtmlEntities(str) { return str.replace(/&([^;]+);/g, function (entity, entityCode) { - var match; + let match; if (entityCode in htmlEntities) { return htmlEntities[entityCode]; - /*eslint no-cond-assign: 0*/ } else if ((match = entityCode.match(/^#x([\da-fA-F]+)$/))) { return String.fromCharCode(parseInt(match[1], 16)); - /*eslint no-cond-assign: 0*/ } else if ((match = entityCode.match(/^#(\d+)$/))) { return String.fromCharCode(~~match[1]); } else { diff --git a/src/modules/music.js b/src/modules/music.js index 9bfb256..0bad032 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -382,7 +382,10 @@ async function enqueue({ fields: [ { name: "Title", - value: (title ? `[${title}](${url})` : url).substring(0, 1024), + value: (title && title != url + ? `[${title}](${url})` + : url + ).substring(0, 1024), inline: true, }, { @@ -492,7 +495,7 @@ command.callback = async function ( type = "file"; } else if (msg.attachments.size > 0) { const entries = [...msg.attachments.values()].filter((attachment) => - REGEX_FILE.test(attachment.url) + attachment.contentType.startsWith("audio/") ); if (entries.length > 0) { type = "file"; @@ -571,8 +574,8 @@ command.callback = async function ( } } else { if (argStr.match(/^https?:\/\//)) { - const contentType = await fetch(argStr).then((res) => - res.headers.get("Content-Type") + const contentType = await fetch(argStr, {method: "HEAD"}).then( + (res) => res.headers.get("Content-Type") ); if ( contentType.startsWith("audio/") || @@ -681,9 +684,10 @@ command.callback = async function ( fields: [ { name: "Title", - value: nowPlaying.title + value: (nowPlaying.title && nowPlaying.title != nowPlaying.url ? `[${nowPlaying.title}](${nowPlaying.url})` - : nowPlaying.url, + : nowPlaying.url + ).substring(0, 1024), inline: true, }, {