From e6e38fb4e413cca56f83d21bf4c840afdd51f450 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 16 May 2019 14:29:39 +0000 Subject: [PATCH] Fix some things --- README.md | 3 +-- commands/events/word-of-the-day.js | 36 ------------------------------ commands/games/word-chain.js | 13 ++++------- commands/search/anime.js | 9 +------- commands/search/define.js | 21 +++++++---------- commands/search/manga.js | 3 +-- package.json | 2 +- 7 files changed, 16 insertions(+), 71 deletions(-) delete mode 100644 commands/events/word-of-the-day.js diff --git a/README.md b/README.md index 4a7d5eeb..ade0b736 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 (344) +## Commands (343) ### Utility: * **eval:** Executes JavaScript code. @@ -156,7 +156,6 @@ Xiao is a Discord bot coded in JavaScript with * **neko-atsume-password:** Responds with today's Neko Atsume password. * **time:** Responds with the current time in a particular location. * **today-in-history:** Responds with an event that occurred today in history. -* **word-of-the-day:** Responds with today's word of the day. ### Search: diff --git a/commands/events/word-of-the-day.js b/commands/events/word-of-the-day.js deleted file mode 100644 index cc465d4c..00000000 --- a/commands/events/word-of-the-day.js +++ /dev/null @@ -1,36 +0,0 @@ -const Command = require('../../structures/Command'); -const request = require('node-superfetch'); -const { stripIndents } = require('common-tags'); -const { WORDNIK_KEY } = process.env; - -module.exports = class WordOfTheDayCommand extends Command { - constructor(client) { - super(client, { - name: 'word-of-the-day', - aliases: ['wordnik-word-of-the-day'], - group: 'events', - memberName: 'word-of-the-day', - description: 'Responds with today\'s word of the day.', - credit: [ - { - name: 'Wordnik API', - url: 'https://developer.wordnik.com/' - } - ] - }); - } - - async run(msg) { - try { - const { body } = await request - .get('http://api.wordnik.com/v4/words.json/wordOfTheDay') - .query({ api_key: WORDNIK_KEY }); - return msg.say(stripIndents` - **${body.word}** - (${body.definitions[0].partOfSpeech || '???'}) ${body.definitions[0].text} - `); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/games/word-chain.js b/commands/games/word-chain.js index a9f50ebe..640f1182 100644 --- a/commands/games/word-chain.js +++ b/commands/games/word-chain.js @@ -3,7 +3,7 @@ const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { delay, verify } = require('../../util/Util'); const startWords = require('../../assets/json/word-list'); -const { WORDNIK_KEY } = process.env; +const { WEBSTER_KEY } = process.env; module.exports = class WordChainCommand extends Command { constructor(client) { @@ -110,14 +110,9 @@ module.exports = class WordChainCommand extends Command { async verifyWord(word) { try { const { body } = await request - .get(`http://api.wordnik.com/v4/word.json/${word}/definitions`) - .query({ - limit: 1, - includeRelated: false, - useCanonical: false, - api_key: WORDNIK_KEY - }); - if (!body.length || body[0].word.toLowerCase() !== word) return false; + .get(`https://www.dictionaryapi.com/api/v3/references/collegiate/json/${word}`) + .query({ key: WEBSTER_KEY }); + if (!body.length) return false; return true; } catch (err) { if (err.status === 404) return false; diff --git a/commands/search/anime.js b/commands/search/anime.js index 88d5a6d4..038c5f60 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -106,18 +106,11 @@ module.exports = class AnimeCommand extends Command { .send({ variables: { search: query, - type: 'ANIME', - isAdult: Boolean(nsfw) + type: 'ANIME' }, query: searchGraphQL }); if (!body.data.anime.results.length) return null; - const found = body.data.anime.results.find(anime => { - if (anime.title.english && anime.title.english.toLowerCase() === query) return true; - if (anime.title.romaji && anime.title.romaji.toLowerCase() === query) return true; - return false; - }); - if (found) return found.id; return body.data.anime.results[0].id; } diff --git a/commands/search/define.js b/commands/search/define.js index 300fed25..7724246c 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -1,20 +1,20 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); -const { WORDNIK_KEY } = process.env; +const { WEBSTER_KEY } = process.env; module.exports = class DefineCommand extends Command { constructor(client) { super(client, { name: 'define', - aliases: ['dictionary', 'wordnik'], + aliases: ['dictionary', 'webster'], group: 'search', memberName: 'define', description: 'Defines a word.', credit: [ { - name: 'Wordnik API', - url: 'https://developer.wordnik.com/' + name: 'Merriam-Webster\'s Collegiate® Dictionary', + url: 'https://dictionaryapi.com/products/api-collegiate-dictionary' } ], args: [ @@ -31,18 +31,13 @@ module.exports = class DefineCommand extends Command { async run(msg, { word }) { try { const { body } = await request - .get(`http://api.wordnik.com/v4/word.json/${word}/definitions`) - .query({ - limit: 1, - includeRelated: false, - useCanonical: true, - api_key: WORDNIK_KEY - }); + .get(`https://www.dictionaryapi.com/api/v3/references/collegiate/json/${word}`) + .query({ key: WEBSTER_KEY }); if (!body.length) return msg.say('Could not find any results.'); const data = body[0]; return msg.say(stripIndents` - **${data.word}** - (${data.partOfSpeech || 'unknown'}) ${data.text} + **${data.stems[0]}** (${data.fl}) + ${data.shortdef.map((definition, i) => `(${i + 1}) ${definition}`).join('\n')} `); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/search/manga.js b/commands/search/manga.js index 15974a2a..1ba82051 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -91,8 +91,7 @@ module.exports = class MangaCommand extends Command { .send({ variables: { search: query, - type: 'MANGA', - isAdult: Boolean(nsfw) + type: 'MANGA' }, query: searchGraphQL }); diff --git a/package.json b/package.json index 08d2c5ce..a11aef89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "103.0.4", + "version": "104.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {