mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
Anime Figure Command
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = class AnimeFigureCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'anime-figure',
|
||||
aliases: ['my-figure-collection', 'mfc', 'figure'],
|
||||
group: 'search',
|
||||
memberName: 'anime-figure',
|
||||
description: 'Searches MyFigureCollection for your query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'MyFigureCollection.net',
|
||||
url: 'https://myfigurecollection.net/',
|
||||
reason: 'Figure Data'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What figure would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const location = await this.search(query);
|
||||
if (!location) return msg.say('Could not find any results.');
|
||||
return msg.say(location);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { text } = await request
|
||||
.get('https://myfigurecollection.net/browse.v4.php')
|
||||
.query({ keywords: query });
|
||||
const $ = cheerio.load(text);
|
||||
const location = $('span[class="item-icon"]').first().children().first().attr('href');
|
||||
if (!location) return null;
|
||||
return `https://myfigurecollection.net${location}`;
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "134.12.0",
|
||||
"version": "134.13.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"private": true,
|
||||
|
||||
Reference in New Issue
Block a user