mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 18:29:14 +02:00
Ghibli Command
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
|
||||||
|
module.exports = class GhibliCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'ghibli',
|
||||||
|
aliases: ['studio-ghibli', 'ghibli-person', 'studio-ghibli-person'],
|
||||||
|
group: 'search',
|
||||||
|
memberName: 'ghibli',
|
||||||
|
description: 'Searches Studio Ghibli people for your query.',
|
||||||
|
clientPermissions: ['EMBED_LINKS'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'query',
|
||||||
|
prompt: 'What person would you like to search for?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { query }) {
|
||||||
|
try {
|
||||||
|
const { body } = await snekfetch
|
||||||
|
.get('http://ghibliapi.herokuapp.com/people')
|
||||||
|
.query({ name: query });
|
||||||
|
if (!body.length) return msg.say('Could not find any results.');
|
||||||
|
const data = body[0];
|
||||||
|
const species = await snekfetch.get(data.species);
|
||||||
|
const films = [];
|
||||||
|
for (const film of data.films) {
|
||||||
|
const movie = await snekfetch.get(film);
|
||||||
|
films.push(movie.body);
|
||||||
|
}
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(0xE7E7E7)
|
||||||
|
.setAuthor('Studio Ghibli', 'https://i.imgur.com/P3YafQ3.jpg')
|
||||||
|
.setTitle(data.name)
|
||||||
|
.addField('❯ Gender',
|
||||||
|
data.gender, true)
|
||||||
|
.addField('❯ Age',
|
||||||
|
data.age, true)
|
||||||
|
.addField('❯ Species',
|
||||||
|
species.body.name, true)
|
||||||
|
.addField('❯ Eye Color',
|
||||||
|
data.eye_color, true)
|
||||||
|
.addField('❯ Hair Color',
|
||||||
|
data.hair_color, true)
|
||||||
|
.addField('❯ Films',
|
||||||
|
films.map(film => film.title).join('\n'), true);
|
||||||
|
return msg.embed(embed);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "42.8.0",
|
"version": "42.9.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user