2019-09-13 20:02:41 +00:00
|
|
|
const urlCheck = require("../utils/urlcheck.js");
|
2019-10-28 16:02:00 +00:00
|
|
|
const fetch = require("node-fetch");
|
2019-09-13 20:02:41 +00:00
|
|
|
|
|
|
|
exports.run = async (message, args) => {
|
|
|
|
message.channel.sendTyping();
|
|
|
|
if (args.length === 0 || !urlCheck(args[0])) return `${message.author.mention}, you need to provide a short URL to lengthen!`;
|
|
|
|
if (urlCheck(args[0])) {
|
2020-08-06 19:21:48 +00:00
|
|
|
const url = await fetch(encodeURI(args[0]), { redirect: "manual" });
|
2019-10-28 16:02:00 +00:00
|
|
|
return url.headers.get("location") || args[0];
|
2020-08-06 19:21:48 +00:00
|
|
|
} else {
|
|
|
|
return `${message.author.mention}, that isn't a URL!`;
|
2019-09-13 20:02:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.aliases = ["longurl", "lengthenurl", "longuri", "lengthenuri", "unshorten"];
|
2019-12-02 20:47:22 +00:00
|
|
|
exports.category = 1;
|
2019-12-05 16:58:46 +00:00
|
|
|
exports.help = "Lengthens a short URL";
|
|
|
|
exports.params = "[url]";
|