Neopets improvements

This commit is contained in:
Daniel Odendahl Jr
2017-12-07 23:53:31 +00:00
parent fe400d398e
commit f2cbd19d63
2 changed files with 22 additions and 3 deletions
+21 -2
View File
@@ -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.');
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "56.3.0",
"version": "56.3.1",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {