diff --git a/commands/games/hangman.js b/commands/games/hangman.js index 891721fc..5d86607d 100644 --- a/commands/games/hangman.js +++ b/commands/games/hangman.js @@ -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 = []; diff --git a/commands/random-res/history.js b/commands/random-res/history.js index a1152a1d..5ae95b39 100644 --- a/commands/random-res/history.js +++ b/commands/random-res/history.js @@ -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!`); } } diff --git a/commands/random-res/name.js b/commands/random-res/name.js index 0f60d1d6..70100f8a 100644 --- a/commands/random-res/name.js +++ b/commands/random-res/name.js @@ -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.', diff --git a/commands/search/anime.js b/commands/search/anime.js index 32a0e7f3..a7d5647f 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -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) diff --git a/commands/search/itunes.js b/commands/search/itunes.js index 09dfc587..72581008 100644 --- a/commands/search/itunes.js +++ b/commands/search/itunes.js @@ -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) diff --git a/commands/search/manga.js b/commands/search/manga.js index eb5497c8..3ca2bdd4 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -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) diff --git a/commands/search/new-york-times.js b/commands/search/new-york-times.js index dc304043..70d18c9c 100644 --- a/commands/search/new-york-times.js +++ b/commands/search/new-york-times.js @@ -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() diff --git a/commands/search/rotten-tomatoes.js b/commands/search/rotten-tomatoes.js index 615c00c6..512cefd8 100644 --- a/commands/search/rotten-tomatoes.js +++ b/commands/search/rotten-tomatoes.js @@ -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!`); diff --git a/commands/search/safebooru.js b/commands/search/safebooru.js index 399c8e6b..f9fc75a6 100644 --- a/commands/search/safebooru.js +++ b/commands/search/safebooru.js @@ -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} diff --git a/commands/search/steam.js b/commands/search/steam.js index 8d88f322..aa56ea38 100644 --- a/commands/search/steam.js +++ b/commands/search/steam.js @@ -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', diff --git a/commands/search/vocaloid.js b/commands/search/vocaloid.js index c84cfbed..45c6494d 100644 --- a/commands/search/vocaloid.js +++ b/commands/search/vocaloid.js @@ -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() diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index 7183d236..8f7db890 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -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 diff --git a/commands/search/weather.js b/commands/search/weather.js index c4243439..060d5b2c 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -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 }); diff --git a/package.json b/package.json index 0cbaed94..3af66c78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "46.3.2", + "version": "47.0.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {