More fixes

This commit is contained in:
Daniel Odendahl Jr
2019-05-16 14:57:13 +00:00
parent 3bc076319c
commit c6f65d1774
5 changed files with 3 additions and 138 deletions
-40
View File
@@ -1,40 +0,0 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { GOOGLE_KEY } = process.env;
module.exports = class ShortenURLCommand extends Command {
constructor(client) {
super(client, {
name: 'shorten-url',
aliases: ['short-url', 'url-shorten'],
group: 'text-edit',
memberName: 'shorten-url',
description: 'Creates a goo.gl short URL from another URL.',
credit: [
{
name: 'Google URL Shortener API',
url: 'https://developers.google.com/url-shortener/'
}
],
args: [
{
key: 'url',
prompt: 'What url do you want to shorten?',
type: 'string'
}
]
});
}
async run(msg, { url }) {
try {
const { body } = await request
.post('https://www.googleapis.com/urlshortener/v1/url')
.query({ key: GOOGLE_KEY })
.send({ longUrl: url });
return msg.say(`<${body.id}>`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};