diff --git a/commands/search/neopet.js b/commands/search/neopet.js index a5d6a34b..90c0b641 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -1,5 +1,13 @@ const { Command } = require('discord.js-commando'); const snekfetch = require('snekfetch'); +const { list } = require('../../util/Util'); +const moods = { + happy: 1, + sad: 2, + angry: 3, + sick: 4, + none: 5 +}; module.exports = class NeopetCommand extends Command { constructor(client) { @@ -14,19 +22,30 @@ module.exports = class NeopetCommand extends Command { key: 'pet', prompt: 'What pet would you like to get an image of?', type: 'string' + }, + { + key: 'mood', + prompt: `What mood should the pet be in? Either ${list(Object.keys(moods), 'or')}.`, + type: 'string', + default: 'happy', + validate: mood => { + if (moods[mood.toLowerCase()]) return true; + return `Invalid mood, please enter either ${list(Object.keys(moods), 'or')}.`; + }, + parse: mood => mood.toLowerCase() } ] }); } - async run(msg, { pet }) { + async run(msg, { pet, mood }) { try { const { text } = await snekfetch .get('http://www.sunnyneo.com/petimagefinder.php') .query({ name: pet, size: 5, - mood: 1 + mood: moods[mood] }); const link = text.match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/); if (!link) return msg.say('Could not find any results.'); diff --git a/package.json b/package.json index 4e1dbc55..e0a785fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "56.3.0", + "version": "56.3.1", "description": "Your personal server companion.", "main": "XiaoBot.js", "scripts": {