music: fix attachments cause of url params, fix now playing trying to masked link urls
This commit is contained in:
parent
5ddb990aff
commit
ef94755fca
2 changed files with 11 additions and 9 deletions
|
@ -372,14 +372,12 @@ const htmlEntities = {
|
||||||
|
|
||||||
function parseHtmlEntities(str) {
|
function parseHtmlEntities(str) {
|
||||||
return str.replace(/&([^;]+);/g, function (entity, entityCode) {
|
return str.replace(/&([^;]+);/g, function (entity, entityCode) {
|
||||||
var match;
|
let match;
|
||||||
|
|
||||||
if (entityCode in htmlEntities) {
|
if (entityCode in htmlEntities) {
|
||||||
return htmlEntities[entityCode];
|
return htmlEntities[entityCode];
|
||||||
/*eslint no-cond-assign: 0*/
|
|
||||||
} else if ((match = entityCode.match(/^#x([\da-fA-F]+)$/))) {
|
} else if ((match = entityCode.match(/^#x([\da-fA-F]+)$/))) {
|
||||||
return String.fromCharCode(parseInt(match[1], 16));
|
return String.fromCharCode(parseInt(match[1], 16));
|
||||||
/*eslint no-cond-assign: 0*/
|
|
||||||
} else if ((match = entityCode.match(/^#(\d+)$/))) {
|
} else if ((match = entityCode.match(/^#(\d+)$/))) {
|
||||||
return String.fromCharCode(~~match[1]);
|
return String.fromCharCode(~~match[1]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -382,7 +382,10 @@ async function enqueue({
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Title",
|
name: "Title",
|
||||||
value: (title ? `[${title}](${url})` : url).substring(0, 1024),
|
value: (title && title != url
|
||||||
|
? `[${title}](${url})`
|
||||||
|
: url
|
||||||
|
).substring(0, 1024),
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -492,7 +495,7 @@ command.callback = async function (
|
||||||
type = "file";
|
type = "file";
|
||||||
} else if (msg.attachments.size > 0) {
|
} else if (msg.attachments.size > 0) {
|
||||||
const entries = [...msg.attachments.values()].filter((attachment) =>
|
const entries = [...msg.attachments.values()].filter((attachment) =>
|
||||||
REGEX_FILE.test(attachment.url)
|
attachment.contentType.startsWith("audio/")
|
||||||
);
|
);
|
||||||
if (entries.length > 0) {
|
if (entries.length > 0) {
|
||||||
type = "file";
|
type = "file";
|
||||||
|
@ -571,8 +574,8 @@ command.callback = async function (
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (argStr.match(/^https?:\/\//)) {
|
if (argStr.match(/^https?:\/\//)) {
|
||||||
const contentType = await fetch(argStr).then((res) =>
|
const contentType = await fetch(argStr, {method: "HEAD"}).then(
|
||||||
res.headers.get("Content-Type")
|
(res) => res.headers.get("Content-Type")
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
contentType.startsWith("audio/") ||
|
contentType.startsWith("audio/") ||
|
||||||
|
@ -681,9 +684,10 @@ command.callback = async function (
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Title",
|
name: "Title",
|
||||||
value: nowPlaying.title
|
value: (nowPlaying.title && nowPlaying.title != nowPlaying.url
|
||||||
? `[${nowPlaying.title}](${nowPlaying.url})`
|
? `[${nowPlaying.title}](${nowPlaying.url})`
|
||||||
: nowPlaying.url,
|
: nowPlaying.url
|
||||||
|
).substring(0, 1024),
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue