mrmBot-Matrix/commands/shorten.js
2019-09-13 15:02:41 -05:00

11 lines
No EOL
497 B
JavaScript

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"];