From 53624abff041bb1ee36d211368f951826bb5514b Mon Sep 17 00:00:00 2001 From: supositware Date: Thu, 16 Jun 2022 23:11:01 +0200 Subject: [PATCH] Check for the url to be a url --- commands/download.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commands/download.js b/commands/download.js index 3200aa1..9e77309 100644 --- a/commands/download.js +++ b/commands/download.js @@ -21,6 +21,11 @@ module.exports = { await interaction.deferReply({ ephemeral: false }); 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')) { let qualitys = await new Promise((resolve, reject) => { exec(`./bin/yt-dlp ${url} --print "%()j"`, (err, stdout, stderr) => {