diff --git a/commands/random/quotes.js b/commands/random/quotes.js new file mode 100644 index 00000000..e9738999 --- /dev/null +++ b/commands/random/quotes.js @@ -0,0 +1,40 @@ +const commando = require('discord.js-commando'); +const request = require('superagent'); +const config = require('../../config.json'); + +module.exports = class QuotesCommand extends commando.Command { + constructor(Client) { + super(Client, { + name: 'quote', + group: 'random', + memberName: 'quote', + description: 'Gets a random quote. (;quote)', + examples: [';quote'] + }); + } + + async run(message) { + if (message.channel.type !== 'dm') { + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + } + console.log(`[Command] ${message.content}`); + let randomTypes = ['movie', 'famous']; + randomTypes = randomTypes[Math.floor(Math.random() * randomTypes.length)]; + return request + .get('https://andruxnet-random-famous-quotes.p.mashape.com/') + .set({ + 'X-Mashape-Key': config.mashapekey, + 'Accept': 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded' + }) + .query({ + cat: randomTypes + }) + .then(function(response) { + return message.channel.send(`"${response.body.quote}"\n - *${response.body.author}*`).catch(error => message.channel.send(':x: Error! Something went wrong!')); + }).catch(function(err) { + console.log(err); + return message.channel.send(":x: Error! Unknown Error. Try again later!"); + }); + } +}; diff --git a/commands/textedit/yoda.js b/commands/textedit/yoda.js index cbdd5f86..7d2b53c7 100644 --- a/commands/textedit/yoda.js +++ b/commands/textedit/yoda.js @@ -33,7 +33,7 @@ module.exports = class YodaCommand extends commando.Command { sentence: turnToYoda }) .then(function(response) { - if (response === undefined) { + if (!response) { return message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'); } else { diff --git a/html/carbondesc.html b/html/carbondesc.html index af757890..b28410c3 100644 --- a/html/carbondesc.html +++ b/html/carbondesc.html @@ -52,7 +52,7 @@