music: support urls if they dont have extensions based on content type
This commit is contained in:
		
							parent
							
								
									7c29a4e983
								
							
						
					
					
						commit
						65c9898ee5
					
				
					 1 changed files with 36 additions and 11 deletions
				
			
		| 
						 | 
					@ -215,7 +215,7 @@ async function enqueue(
 | 
				
			||||||
      highWaterMark: 1 << 25,
 | 
					      highWaterMark: 1 << 25,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  } else if (type == "sc") {
 | 
					  } else if (type == "sc") {
 | 
				
			||||||
    if (url.startsWith("sc:"))
 | 
					    if (url?.startsWith("sc:"))
 | 
				
			||||||
      url = url.replace(/^sc:/, "https://soundcloud.com/");
 | 
					      url = url.replace(/^sc:/, "https://soundcloud.com/");
 | 
				
			||||||
    const client_id = await getSoundcloudClientID();
 | 
					    const client_id = await getSoundcloudClientID();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -537,21 +537,46 @@ command.callback = async function (msg, line) {
 | 
				
			||||||
              queueNext
 | 
					              queueNext
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          if (argStr.match(/https?:\/\//)) {
 | 
				
			||||||
 | 
					            const contentType = await fetch(argStr).then((res) =>
 | 
				
			||||||
 | 
					              res.headers.get("Content-Type")
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            if (
 | 
				
			||||||
 | 
					              contentType.startsWith("audio/") ||
 | 
				
			||||||
 | 
					              contentType.startsWith("video/")
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
 | 
					              await enqueue(
 | 
				
			||||||
 | 
					                msg.guildID,
 | 
				
			||||||
 | 
					                msg.member.voiceState.channelID,
 | 
				
			||||||
 | 
					                msg.channel.id,
 | 
				
			||||||
 | 
					                argStr,
 | 
				
			||||||
 | 
					                "file",
 | 
				
			||||||
 | 
					                msg.author.id,
 | 
				
			||||||
 | 
					                false,
 | 
				
			||||||
 | 
					                queueNext
 | 
				
			||||||
 | 
					              );
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              return "Unsupported content type.";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            const url = await youtubeSearch(msg, argStr);
 | 
					            const url = await youtubeSearch(msg, argStr);
 | 
				
			||||||
          if (url.startsWith("https://youtu.be/")) {
 | 
					            if (url?.startsWith("https://youtu.be/")) {
 | 
				
			||||||
              await enqueue(
 | 
					              await enqueue(
 | 
				
			||||||
                msg.guildID,
 | 
					                msg.guildID,
 | 
				
			||||||
                msg.member.voiceState.channelID,
 | 
					                msg.member.voiceState.channelID,
 | 
				
			||||||
                msg.channel.id,
 | 
					                msg.channel.id,
 | 
				
			||||||
                url,
 | 
					                url,
 | 
				
			||||||
                "yt",
 | 
					                "yt",
 | 
				
			||||||
              msg.author.id
 | 
					                msg.author.id,
 | 
				
			||||||
 | 
					                false,
 | 
				
			||||||
 | 
					                queueNext
 | 
				
			||||||
              );
 | 
					              );
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              return url;
 | 
					              return url;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        return "You are not in a voice channel.";
 | 
					        return "You are not in a voice channel.";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue