mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 13:53:12 +02:00
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
const { Command } = require('discord.js-commando');
|
|
const request = require('superagent');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = class NeopetCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'neopet',
|
|
group: 'search',
|
|
memberName: 'neopet',
|
|
description: 'Gives a Neopet\'s image, searchable by name.',
|
|
args: [{
|
|
key: 'pet',
|
|
prompt: 'What pet would you like to get the image of?',
|
|
type: 'string',
|
|
parse: text => encodeURIComponent(text)
|
|
}]
|
|
});
|
|
}
|
|
|
|
async run(message, args) {
|
|
const { pet } = args;
|
|
try {
|
|
const { text } = await request
|
|
.get(`http://www.sunnyneo.com/petimagefinder.php?name=${pet}&size=5&mood=1`);
|
|
const $ = cheerio.load(text);
|
|
const link = $('textarea').first().text();
|
|
if (!link.includes('cp'))
|
|
return message.say('This is not a valid pet name.');
|
|
return message.say(link);
|
|
} catch (err) {
|
|
return message.say('An Unknown Error Occurred.');
|
|
}
|
|
}
|
|
};
|