Check for the url to be a url

This commit is contained in:
supositware 2022-06-16 23:11:01 +02:00
parent 14ee901846
commit 53624abff0

View file

@ -21,6 +21,11 @@ module.exports = {
await interaction.deferReply({ ephemeral: false }); await interaction.deferReply({ ephemeral: false });
const url = interaction.options.getString('url'); const url = interaction.options.getString('url');
const urlRE = new RegExp('([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?([^ ])+');
if (!url.match(urlRE)) {
return interaction.editReply({ content: '❌ This does not look like a valid URL!', ephemeral: true });
}
if (interaction.options.getBoolean('advanced')) { if (interaction.options.getBoolean('advanced')) {
let qualitys = await new Promise((resolve, reject) => { let qualitys = await new Promise((resolve, reject) => {
exec(`./bin/yt-dlp ${url} --print "%()j"`, (err, stdout, stderr) => { exec(`./bin/yt-dlp ${url} --print "%()j"`, (err, stdout, stderr) => {