From dbebb656b690a8a3683843e5bb991094fa99202f Mon Sep 17 00:00:00 2001 From: Keanu Date: Thu, 22 Oct 2020 13:38:57 +0000 Subject: [PATCH] Added shorten command. --- src/commands/utilities/shorten.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/commands/utilities/shorten.ts diff --git a/src/commands/utilities/shorten.ts b/src/commands/utilities/shorten.ts new file mode 100644 index 0000000..e58b528 --- /dev/null +++ b/src/commands/utilities/shorten.ts @@ -0,0 +1,25 @@ +import Command from '../../core/command'; +import { CommonLibrary } from '../../core/lib'; +import * as https from 'https'; + +export default new Command({ + description: 'Shortens a given URL.', + run: 'Please provide a URL.', + any: new Command({ + async run($: CommonLibrary): Promise { + https.get( + 'https://is.gd/create.php?format=simple&url=' + + encodeURIComponent($.args[0]), + function (res) { + var body = ''; + res.on('data', function (chunk) { + body += chunk; + }); + res.on('end', function () { + $.channel.send(`<${body}>`); + }); + }, + ); + }, + }), +});