mrmBot-Matrix/commands/shorten.js

14 lines
578 B
JavaScript
Raw Normal View History

2019-09-13 20:02:41 +00:00
const urlCheck = require("../utils/urlcheck.js");
const fetch = require("node-fetch");
exports.run = async (message, args) => {
if (args.length === 0 || !urlCheck(args[0])) return `${message.author.mention}, you need to provide a URL to shorten!`;
const data = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURIComponent(args[0])}`);
const url = await data.text();
return url;
};
exports.aliases = ["urlshorten", "shortenlink", "urishorten", "shortenuri", "shortenurl"];
exports.category = 1;
exports.help = "Shortens a URL";
exports.params = "[url]";