TravBot-v3/src/commands/utility/shorten.ts

21 lines
644 B
TypeScript
Raw Normal View History

import {Command, NamedCommand} from "onion-lasers";
2020-12-15 01:44:28 +00:00
import * as https from "https";
export default new NamedCommand({
2020-12-15 01:44:28 +00:00
description: "Shortens a given URL.",
run: "Please provide a URL.",
any: new Command({
async run({send, args}) {
https.get("https://is.gd/create.php?format=simple&url=" + encodeURIComponent(args[0]), function (res) {
2020-12-15 07:56:09 +00:00
var body = "";
res.on("data", function (chunk) {
body += chunk;
});
res.on("end", function () {
2021-04-10 13:34:55 +00:00
send(`<${body}>`);
2020-12-15 07:56:09 +00:00
});
});
2020-12-15 01:44:28 +00:00
}
})
});