Fix some things

This commit is contained in:
Daniel Odendahl Jr
2019-05-16 14:29:39 +00:00
parent 7a86c80c23
commit e6e38fb4e4
7 changed files with 16 additions and 71 deletions
+1 -2
View File
@@ -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:
-36
View File
@@ -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!`);
}
}
};
+4 -9
View File
@@ -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;
+1 -8
View File
@@ -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;
}
+8 -13
View File
@@ -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!`);
+1 -2
View File
@@ -91,8 +91,7 @@ module.exports = class MangaCommand extends Command {
.send({
variables: {
search: query,
type: 'MANGA',
isAdult: Boolean(nsfw)
type: 'MANGA'
},
query: searchGraphQL
});
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "103.0.4",
"version": "104.0.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {