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) {
 | 
			
		||||
  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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue