Quote Command - Beta

This commit is contained in:
Daniel Odendahl Jr
2017-03-23 17:07:04 +00:00
parent 7d1b54b5e6
commit 0b032fdce6
4 changed files with 43 additions and 3 deletions
+40
View File
@@ -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!");
});
}
};
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -52,7 +52,7 @@
<h2>Information</h2>
<ul>
<li><a href="https://discord.gg/fqQF8mc">Home Server</a></li>
<li>Command Count: 108</li>
<li>Command Count: 109</li>
<li>Server Host: <a href="https://www.heroku.com/">Heroku</a></li>
</ul>
</div>
+1 -1
View File
@@ -100,7 +100,7 @@
<h2>Information</h2>
<ul>
<li><a href="https://discord.gg/fqQF8mc">Home Server</a></li>
<li>Command Count: 108</li>
<li>Command Count: 109</li>
<li>Server Host: <a href="https://www.heroku.com/">Heroku</a></li>
</ul>
</div>