Move to snekfetch 🐍

This commit is contained in:
Daniel Odendahl Jr
2017-04-16 01:12:22 +00:00
parent 90d3e66e89
commit 8074fe51bd
36 changed files with 252 additions and 311 deletions
+4 -7
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const request = require('superagent');
const snekfetch = require('snekfetch');
module.exports = class YodaCommand extends Command {
constructor(client) {
@@ -21,16 +21,13 @@ module.exports = class YodaCommand extends Command {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const text = args.text;
const text = encodeURIComponent(args.text);
try {
const response = await request
.get('https://yoda.p.mashape.com/yoda')
const response = await snekfetch
.get(`https://yoda.p.mashape.com/yoda?sentence=${text}`)
.set({
'X-Mashape-Key': process.env.MASHAPE_KEY,
'Accept': 'text/plain'
})
.query({
sentence: text
});
return message.say(`\u180E${response.text}`);
}