diff --git a/commands/fun/randocat.js b/commands/fun/randocat.js index 41f8ce9..81ae880 100644 --- a/commands/fun/randocat.js +++ b/commands/fun/randocat.js @@ -1,24 +1,27 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); -const snekfetch = require('snekfetch'); -module.exports = class RandoCatCommand extends Command { +const fetch = require('node-fetch') +module.exports = class RandoDogCommand extends Command { constructor(client) { super(client, { - name: 'randocat', + name: 'randodog', group: 'fun', - memberName: 'randocat', - description: `Show a random cat`, + memberName: 'randodog', + description: `Show a random dog`, }); } - async run(message, { city }) { - const { body } = await snekfetch.get(`http://aws.random.cat/meow`); - const dogEmbed = new Discord.RichEmbed() + async run(message) { + + fetch("http://aws.random.cat/meow").then((response) => { + return response.json(); +}).then((response) => { + const catEmbed = new Discord.RichEmbed() .setColor("#ff9900") .setTitle('Meow') - .setImage(body.file) + .setImage(response.file) - message.say(dogEmbed); - } -}; \ No newline at end of file + message.say(catEmbed); + }); +}}; \ No newline at end of file diff --git a/commands/fun/randodog.js b/commands/fun/randodog.js index ea570fb..408bb40 100644 --- a/commands/fun/randodog.js +++ b/commands/fun/randodog.js @@ -1,24 +1,27 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); -const snekfetch = require('snekfetch'); -module.exports = class RandoDogCommand extends Command { +const fetch = require('node-fetch') +module.exports = class RandoCatCommand extends Command { constructor(client) { super(client, { - name: 'randodog', + name: 'randocat', group: 'fun', - memberName: 'randodog', - description: `Show a random doggy`, + memberName: 'randocat', + description: `Show a random cat`, }); } - async run(message, { city }) { - const { body } = await snekfetch.get(`https://random.dog/woof.json`); + async run(message) { + + fetch("https://random.dog/woof.json").then((response) => { + return response.json(); +}).then((response) => { const dogEmbed = new Discord.RichEmbed() .setColor("#ff9900") - .setTitle('Woof') - .setImage(body.url) + .setTitle('Meow') + .setImage(response.file) message.say(dogEmbed); - } -}; \ No newline at end of file + }); +}}; \ No newline at end of file diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index c8189c9..f40810e 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); -const snekfetch = require('snekfetch'); +const fetch = require('node-fetch'); module.exports = class redditCommand extends Command { constructor(client) { super(client, { @@ -19,26 +19,29 @@ module.exports = class redditCommand extends Command { } async run(message, { sub }) { - const { body } = await snekfetch.get('https://www.reddit.com/r/' + sub + '.json?limit=100'); let /* the bodies hit the floor */ i = Math.floor((Math.random() * 10) + 1); let a = 0 - if (!body.data.children[1]) - return message.say('Not a valid subreddit') - while (body.data.children[i].data.post_hint !== 'image') { - i = Math.floor((Math.random() * 100) + 1); - a++ - if (a == 5) - return message.say("Could not find any images") - } - if (body.data.children[i].data.over_18 == true) - return message.say("No nsfw ( if you want a nsfw version of this commands use the feedback commands \"haha feedback \")") - const redditEmbed = new Discord.RichEmbed() - .setColor("#ff9900") - .setTitle(body.data.children[i].data.title) - .setImage(body.data.children[i].data.url) - .setURL('https://reddit.com' + body.data.children[i].data.permalink) - .setFooter(`⬆ ${body.data.children[i].data.ups} 💬 ${body.data.children[i].data.num_comments}`) - - message.say(redditEmbed); - } - } \ No newline at end of file + fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => { + return response.json(); + }).then((response) => { + if (!response.data) + return message.say('Not a valid subreddit') + while (response.data.children[i].data.post_hint !== 'image') { + i = Math.floor((Math.random() * 100) + 1); + a++ + if (a == 5) + return message.say("Could not find any images") + } + if (response.data.children[i].data.over_18 == true) + return message.say("No nsfw ( if you want a nsfw version of this commands use the feedback commands \"haha feedback \")") + const redditEmbed = new Discord.RichEmbed() + .setColor("#ff9900") + .setTitle(response.data.children[i].data.title) + .setImage(response.data.children[i].data.url) + .setURL('https://reddit.com' + response.data.children[i].data.permalink) + .setFooter(`⬆ ${response.data.children[i].data.ups} 💬 ${response.data.children[i].data.num_comments}`) + + message.say(redditEmbed); + } + +)}} \ No newline at end of file diff --git a/package.json b/package.json index fe8ffbb..5e845b1 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "dependencies": { "discord.js": "^11.4.2", "discord.js-commando": "^0.10.0", - "snekfetch": "^4.0.4" + "node-fetch": "^2.2.0" } }