mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 14:20:51 +02:00
Changes are fun
This commit is contained in:
@@ -21,15 +21,7 @@ module.exports = class HangmanCommand extends Command {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.wordnik.com/v4/words.json/randomWord')
|
||||
.query({
|
||||
minCorpusCount: 0,
|
||||
maxCorpusCount: -1,
|
||||
minDictionaryCount: 1,
|
||||
maxDictionaryCount: -1,
|
||||
minLength: -1,
|
||||
maxLength: -1,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
.query({ api_key: WORDNIK_KEY });
|
||||
const word = body.word.toLowerCase().replace(/ /g, '-');
|
||||
let points = 0;
|
||||
const confirmation = [];
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = class HistoryCommand extends Command {
|
||||
event.links.map(link => `[${link.title}](${link.link.replace(/\)/g, '%29')})`).join(', '));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404 || err.status === 500) return msg.say('Could not find any results.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ module.exports = class NameCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'name',
|
||||
aliases: ['random-person'],
|
||||
group: 'random-res',
|
||||
memberName: 'name',
|
||||
description: 'Responds with a random name, with the gender of your choice.',
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = class AnimeCommand extends Command {
|
||||
.get('https://kitsu.io/api/edge/anime')
|
||||
.query({ 'filter[text]': query });
|
||||
const body = JSON.parse(text);
|
||||
if (!body.meta.count) return msg.say('Could not find any results.');
|
||||
if (!body.data.length) return msg.say('Could not find any results.');
|
||||
const data = body.data[0].attributes;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xF75239)
|
||||
|
||||
@@ -46,7 +46,7 @@ module.exports = class ITunesCommand extends Command {
|
||||
country
|
||||
});
|
||||
const body = JSON.parse(text);
|
||||
if (!body.resultCount) return msg.say('Could not find any results.');
|
||||
if (!body.results.length) return msg.say('Could not find any results.');
|
||||
const data = body.results[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFEFEFE)
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = class MangaCommand extends Command {
|
||||
.get('https://kitsu.io/api/edge/manga')
|
||||
.query({ 'filter[text]': query });
|
||||
const body = JSON.parse(text);
|
||||
if (!body.meta.count) return msg.say('Could not find any results.');
|
||||
if (!body.data.length) return msg.say('Could not find any results.');
|
||||
const data = body.data[0].attributes;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xF75239)
|
||||
|
||||
@@ -15,9 +15,8 @@ module.exports = class NewYorkTimesCommand extends Command {
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What article do you want to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
prompt: 'What do you want to search for articles about?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -25,14 +24,13 @@ module.exports = class NewYorkTimesCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const fetch = snekfetch
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.nytimes.com/svc/search/v2/articlesearch.json')
|
||||
.query({
|
||||
q: query,
|
||||
'api-key': NYTIMES_KEY,
|
||||
sort: 'newest'
|
||||
});
|
||||
if (query) fetch.query({ q: query });
|
||||
const { body } = await fetch;
|
||||
if (!body.response.docs.length) return msg.say('Could not find any results');
|
||||
const data = body.response.docs[Math.floor(Math.random() * body.response.docs.length)];
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
@@ -34,18 +34,18 @@ module.exports = class RottenTomatoesCommand extends Command {
|
||||
const find = search.body.movies.find(m => m.name.toLowerCase() === query.toLowerCase()) || search.body.movies[0];
|
||||
const urlID = find.url.replace('/m/', '');
|
||||
const { text } = await snekfetch.get(`https://www.rottentomatoes.com/api/private/v1.0/movies/${urlID}`);
|
||||
const data = JSON.parse(text);
|
||||
const body = JSON.parse(text);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFFEC02)
|
||||
.setTitle(`${data.title} (${data.year})`)
|
||||
.setURL(`https://www.rottentomatoes.com${data.url}`)
|
||||
.setTitle(`${body.title} (${body.year})`)
|
||||
.setURL(`https://www.rottentomatoes.com${body.url}`)
|
||||
.setAuthor('Rotten Tomatoes', 'https://i.imgur.com/Sru8mZ3.jpg')
|
||||
.setDescription(shorten(data.ratingSummary.consensus))
|
||||
.setThumbnail(data.posters.original)
|
||||
.setDescription(shorten(body.ratingSummary.consensus))
|
||||
.setThumbnail(body.posters.original)
|
||||
.addField('❯ Critic Score',
|
||||
data.ratings.critics_score !== -1 ? `${data.ratings.critics_score}%` : 'N/A', true)
|
||||
body.ratings.critics_score !== -1 ? `${body.ratings.critics_score}%` : 'N/A', true)
|
||||
.addField('❯ Audience Score',
|
||||
data.ratings.audience_score !== -1 ? `${data.ratings.audience_score}%` : 'N/A', true);
|
||||
body.ratings.audience_score !== -1 ? `${body.ratings.audience_score}%` : 'N/A', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class SafebooruCommand extends Command {
|
||||
tags: query
|
||||
});
|
||||
const parsed = xml2js(text, { compact: true }).posts;
|
||||
if (parsed._attributes.count === '0' || !parsed.post.length) return msg.say('Could not find any results.');
|
||||
if (!parsed.post.length) return msg.say('Could not find any results.');
|
||||
return msg.say(stripIndents`
|
||||
Result for ${query}:
|
||||
http:${parsed.post[Math.floor(Math.random() * parsed.post.length)]._attributes.file_url}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { shorten, cleanHTML } = require('../../structures/Util');
|
||||
|
||||
module.exports = class SteamCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -31,11 +30,12 @@ module.exports = class SteamCommand extends Command {
|
||||
l: 'en',
|
||||
term: query
|
||||
});
|
||||
if (!search.body.total) return msg.say('Could not find any results.');
|
||||
if (!search.body.items.length) return msg.say('Could not find any results.');
|
||||
const id = search.body.items[0].id;
|
||||
const { body } = await snekfetch
|
||||
.get('http://store.steampowered.com/api/appdetails')
|
||||
.query({ appids: search.body.items[0].id });
|
||||
const { data } = body[search.body.items[0].id.toString()];
|
||||
.get('https://store.steampowered.com/api/appdetails')
|
||||
.query({ appids: id });
|
||||
const { data } = body[id.toString()];
|
||||
const current = data.price_overview ? data.price_overview.final / 100 : 0;
|
||||
const original = data.price_overview ? data.price_overview.initial / 100 : 0;
|
||||
const price = current === original ? `$${current}` : `~~$${original}~~ $${current}`;
|
||||
@@ -47,7 +47,6 @@ module.exports = class SteamCommand extends Command {
|
||||
.setColor(0x101D2F)
|
||||
.setAuthor('Steam', 'https://i.imgur.com/xxr2UBZ.png')
|
||||
.setTitle(data.name)
|
||||
.setDescription(shorten(cleanHTML(data.short_description)))
|
||||
.setURL(`http://store.steampowered.com/app/${data.steam_appid}`)
|
||||
.setImage(data.header_image)
|
||||
.addField('❯ Price',
|
||||
|
||||
@@ -28,13 +28,12 @@ module.exports = class VocaloidCommand extends Command {
|
||||
.query({
|
||||
query,
|
||||
maxResults: 1,
|
||||
getTotalCount: true,
|
||||
sort: 'FavoritedTimes',
|
||||
preferAccurateMatches: true,
|
||||
nameMatchMode: 'Words',
|
||||
fields: 'ThumbUrl,Lyrics'
|
||||
});
|
||||
if (!body.totalCount) return msg.say('Could not find any results.');
|
||||
if (!body.items.length) return msg.say('Could not find any results.');
|
||||
const data = body.items[0];
|
||||
const { minutes, seconds } = duration(data.lengthSeconds * 1000);
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class WattpadCommand extends Command {
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.wattpad.com:443/v4/stories')
|
||||
.get('https://api.wattpad.com/v4/stories')
|
||||
.query({
|
||||
query,
|
||||
limit: 1
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { list } = require('../../structures/Util');
|
||||
const { OWM_KEY } = process.env;
|
||||
const types = ['zip', 'name'];
|
||||
|
||||
module.exports = class WeatherCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -15,16 +13,6 @@ module.exports = class WeatherCommand extends Command {
|
||||
description: 'Responds with weather information for a specified location.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'type',
|
||||
prompt: `What type should the search be? Either ${list(types, 'or')}.`,
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (types.includes(type)) return true;
|
||||
return `Invalid type, please enter either ${list(types, 'or')}.`;
|
||||
},
|
||||
parse: type => type.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What location would you like to get the weather of?',
|
||||
@@ -34,13 +22,12 @@ module.exports = class WeatherCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { type, query }) {
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.openweathermap.org/data/2.5/weather')
|
||||
.query({
|
||||
q: type === 'name' ? query : '',
|
||||
zip: type === 'zip' ? query : '',
|
||||
q: query,
|
||||
units: 'metric',
|
||||
appid: OWM_KEY
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "46.3.2",
|
||||
"version": "47.0.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user