mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Neopets improvements
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const snekfetch = require('snekfetch');
|
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 {
|
module.exports = class NeopetCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -14,19 +22,30 @@ module.exports = class NeopetCommand extends Command {
|
|||||||
key: 'pet',
|
key: 'pet',
|
||||||
prompt: 'What pet would you like to get an image of?',
|
prompt: 'What pet would you like to get an image of?',
|
||||||
type: 'string'
|
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 {
|
try {
|
||||||
const { text } = await snekfetch
|
const { text } = await snekfetch
|
||||||
.get('http://www.sunnyneo.com/petimagefinder.php')
|
.get('http://www.sunnyneo.com/petimagefinder.php')
|
||||||
.query({
|
.query({
|
||||||
name: pet,
|
name: pet,
|
||||||
size: 5,
|
size: 5,
|
||||||
mood: 1
|
mood: moods[mood]
|
||||||
});
|
});
|
||||||
const link = text.match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/);
|
const link = text.match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/);
|
||||||
if (!link) return msg.say('Could not find any results.');
|
if (!link) return msg.say('Could not find any results.');
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "56.3.0",
|
"version": "56.3.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "XiaoBot.js",
|
"main": "XiaoBot.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user