From c6f65d1774b29c99d54c118ce08363dbb298170d Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 16 May 2019 14:57:13 +0000 Subject: [PATCH] More fixes --- README.md | 4 +- commands/search/eshop.js | 93 ------------------------------- commands/search/http-cat.js | 2 +- commands/text-edit/shorten-url.js | 40 ------------- package.json | 2 +- 5 files changed, 3 insertions(+), 138 deletions(-) delete mode 100644 commands/search/eshop.js delete mode 100644 commands/text-edit/shorten-url.js diff --git a/README.md b/README.md index ade0b736..46d930ee 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Xiao is a Discord bot coded in JavaScript with 6. Run `npm i -g pm2` to install PM2. 7. Run `pm2 start Xiao.js --name xiao` to run the bot. -## Commands (343) +## Commands (341) ### Utility: * **eval:** Executes JavaScript code. @@ -169,7 +169,6 @@ Xiao is a Discord bot coded in JavaScript with * **derpibooru:** Responds with an image from Derpibooru. * **deviantart:** Responds with an image from a DeviantArt section, with optional query. * **docs:** Searches the Discord.js docs for your query. -* **eshop:** Searches the Nintendo eShop for your query. * **esrb:** Searches ESRB for your query. * **flickr:** Searches Flickr for your query. * **giphy:** Searches Giphy for your query. @@ -376,7 +375,6 @@ Xiao is a Discord bot coded in JavaScript with * **sha-1:** Creates a hash of text with the SHA-1 algorithm. * **sha-256:** Creates a hash of text with the SHA-256 algorithm. * **ship-name:** Creates a ship name from two names. -* **shorten-url:** Creates a goo.gl short URL from another URL. * **shuffle:** Shuffles text. * **snake-speak:** Convertsssss text to sssssnake ssssspeak. * **spoiler-letter:** Sends text with each and every character as an individual spoiler. diff --git a/commands/search/eshop.js b/commands/search/eshop.js deleted file mode 100644 index bcc16a1c..00000000 --- a/commands/search/eshop.js +++ /dev/null @@ -1,93 +0,0 @@ -const Command = require('../../structures/Command'); -const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); -const request = require('node-superfetch'); -const { list } = require('../../util/Util'); -const systems = ['3ds', 'switch', 'wii_u']; - -module.exports = class EshopCommand extends Command { - constructor(client) { - super(client, { - name: 'eshop', - aliases: ['nintendo-eshop'], - group: 'search', - memberName: 'eshop', - description: 'Searches the Nintendo eShop for your query.', - clientPermissions: ['EMBED_LINKS'], - credit: [ - { - name: 'Nintendo', - url: 'https://www.nintendo.com/' - } - ], - args: [ - { - key: 'system', - prompt: `What system's store do you want to search? Either ${list(systems, 'or')}.`, - type: 'string', - oneOf: systems, - parse: system => system.toLowerCase() - }, - { - key: 'query', - prompt: 'What game would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { system, query }) { - try { - const id = await this.search(system, query); - if (!id) return msg.say('Could not find any results.'); - const data = await this.fetchGame(id); - const embed = new MessageEmbed() - .setColor(0xFF7D01) - .setAuthor( - `Nintendo eShop (${system})`, - 'https://i.imgur.com/lMh73lz.png', - 'https://www.nintendo.com/games/buy-digital' - ) - .setURL(data.microsite_ref ? data.microsite_ref.microsite.url : null) - .setThumbnail(data.front_box_art.image.image.url) - .setTitle(data.title) - .addField('❯ Price', data.eshop_price - ? data.eshop_price === '0.00' ? 'Free!' : `$${data.eshop_price}` - : '???', true) - .addField('❯ Category', data.game_category_ref - ? data.game_category_ref.length ? data.game_category_ref[0].title : data.game_category_ref.title - : '???', true) - .addField('❯ Release Date', - data.release_date ? moment.utc(data.release_date).format('MM/DD/YYYY') : '???', true) - .addField('❯ Player Count', data.number_of_players || '???', true) - .addField('❯ DLC?', data.dlc === 'true' ? 'Yes' : 'No', true) - .addField('❯ Demo?', data.demo === 'true' ? 'Yes' : 'No', true) - .addField('❯ Developer', data.developer_ref ? data.developer_ref.title : '???', true) - .addField('❯ Publisher', data.publisher_ref ? data.publisher_ref.title : '???', true); - return msg.embed(embed); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } - - async search(system, query) { - const { text } = await request - .get('https://www.nintendo.com/json/content/get/filter/game') - .query({ - system, - sort: 'title', - direction: 'asc', - search: query, - limit: 1, - availability: 'now' - }); - const body = JSON.parse(text); - return body.games.game ? body.games.game.id : null; - } - - async fetchGame(id) { - const { text } = await request.get(`https://www.nintendo.com/json/content/get/game/${id}`); - return JSON.parse(text).game; - } -}; diff --git a/commands/search/http-cat.js b/commands/search/http-cat.js index 41025cc2..3cfb3dff 100644 --- a/commands/search/http-cat.js +++ b/commands/search/http-cat.js @@ -27,7 +27,7 @@ module.exports = class HttpCatCommand extends Command { async run(msg, { code }) { try { - const { body, headers } = await request.get(`https://http.cat/${code}.jpg`); + const { body, headers } = await request.get(`https://http.cat/${code}`); if (headers['content-type'].includes('text/html')) return msg.say('Could not find any results.'); return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] }); } catch (err) { diff --git a/commands/text-edit/shorten-url.js b/commands/text-edit/shorten-url.js deleted file mode 100644 index 5a56c04a..00000000 --- a/commands/text-edit/shorten-url.js +++ /dev/null @@ -1,40 +0,0 @@ -const Command = require('../../structures/Command'); -const request = require('node-superfetch'); -const { GOOGLE_KEY } = process.env; - -module.exports = class ShortenURLCommand extends Command { - constructor(client) { - super(client, { - name: 'shorten-url', - aliases: ['short-url', 'url-shorten'], - group: 'text-edit', - memberName: 'shorten-url', - description: 'Creates a goo.gl short URL from another URL.', - credit: [ - { - name: 'Google URL Shortener API', - url: 'https://developers.google.com/url-shortener/' - } - ], - args: [ - { - key: 'url', - prompt: 'What url do you want to shorten?', - type: 'string' - } - ] - }); - } - - async run(msg, { url }) { - try { - const { body } = await request - .post('https://www.googleapis.com/urlshortener/v1/url') - .query({ key: GOOGLE_KEY }) - .send({ longUrl: url }); - return msg.say(`<${body.id}>`); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/package.json b/package.json index a11aef89..e35c8b47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "104.0.0", + "version": "105.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {