mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Added shorten command.
This commit is contained in:
parent
c959121c03
commit
dbebb656b6
1 changed files with 25 additions and 0 deletions
25
src/commands/utilities/shorten.ts
Normal file
25
src/commands/utilities/shorten.ts
Normal file
|
@ -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<any> {
|
||||
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}>`);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
});
|
Loading…
Reference in a new issue