From a1227cb44675ddd26934de0fc55fbfcc12b5ff52 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 24 Aug 2018 19:04:02 -0400 Subject: [PATCH] Use noopet-image-finder --- commands/search/neopet.js | 13 +++---------- package.json | 1 + 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 1ed70845..1f07ce3c 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const request = require('node-superfetch'); +const petImage = require('neopet-image-finder'); const { list } = require('../../util/Util'); const moods = { happy: 1, @@ -40,16 +40,9 @@ module.exports = class NeopetCommand extends Command { async run(msg, { pet, mood }) { try { - const { text } = await request - .get('http://www.sunnyneo.com/petimagefinder.php') - .query({ - name: pet, - size: 5, - mood: moods[mood] - }); - const link = text.match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/); + const link = await petImage(pet, { mood }); if (!link) return msg.say('Could not find any results.'); - return msg.say(link[0]); + return msg.say(link); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } diff --git a/package.json b/package.json index 80f36675..a95e81ca 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "discord.js-commando": "github:discordjs/Commando", "erlpack": "github:discordapp/erlpack", "mathjs": "^5.1.1", + "neopet-image-finder": "^4.0.0", "node-opus": "^0.3.0", "node-superfetch": "^0.1.4", "random-js": "^1.0.8",