download latest link if no url is passed

This commit is contained in:
supositware 2021-07-23 04:23:43 +02:00
parent dfd25c8bf2
commit 0052248a28

View file

@ -53,6 +53,17 @@ class DownloadCommand extends Command {
} }
async exec(message, args) { 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.link) return message.channel.send('Please try again with a valid URL.');
if (args.listproxy) { if (args.listproxy) {