From 0052248a28bcc42096dfc9d2f8db90f5894a870f Mon Sep 17 00:00:00 2001 From: supositware Date: Fri, 23 Jul 2021 04:23:43 +0200 Subject: [PATCH] download latest link if no url is passed --- commands/utility/download.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/commands/utility/download.js b/commands/utility/download.js index 3179788d..f62149a0 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -53,6 +53,17 @@ class DownloadCommand extends Command { } async exec(message, args) { + if (args.link === null) { + let 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]+)?([^ ])+'); + await message.channel.messages.fetch({ limit: 10 }).then(messages => { + messages.map(m => { + if (m.content.match(urlRE)) { + args.link = new URL(m.content.match(urlRE)[0]); + } + }); + }); + } + if (!args.link) return message.channel.send('Please try again with a valid URL.'); if (args.listproxy) {