mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Fix some things
This commit is contained in:
@@ -45,7 +45,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
6. Run `npm i -g pm2` to install PM2.
|
6. Run `npm i -g pm2` to install PM2.
|
||||||
7. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
7. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
||||||
|
|
||||||
## Commands (344)
|
## Commands (343)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval:** Executes JavaScript code.
|
* **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.
|
* **neko-atsume-password:** Responds with today's Neko Atsume password.
|
||||||
* **time:** Responds with the current time in a particular location.
|
* **time:** Responds with the current time in a particular location.
|
||||||
* **today-in-history:** Responds with an event that occurred today in history.
|
* **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:
|
### Search:
|
||||||
|
|
||||||
|
|||||||
@@ -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!`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -3,7 +3,7 @@ const request = require('node-superfetch');
|
|||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { delay, verify } = require('../../util/Util');
|
const { delay, verify } = require('../../util/Util');
|
||||||
const startWords = require('../../assets/json/word-list');
|
const startWords = require('../../assets/json/word-list');
|
||||||
const { WORDNIK_KEY } = process.env;
|
const { WEBSTER_KEY } = process.env;
|
||||||
|
|
||||||
module.exports = class WordChainCommand extends Command {
|
module.exports = class WordChainCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -110,14 +110,9 @@ module.exports = class WordChainCommand extends Command {
|
|||||||
async verifyWord(word) {
|
async verifyWord(word) {
|
||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`http://api.wordnik.com/v4/word.json/${word}/definitions`)
|
.get(`https://www.dictionaryapi.com/api/v3/references/collegiate/json/${word}`)
|
||||||
.query({
|
.query({ key: WEBSTER_KEY });
|
||||||
limit: 1,
|
if (!body.length) return false;
|
||||||
includeRelated: false,
|
|
||||||
useCanonical: false,
|
|
||||||
api_key: WORDNIK_KEY
|
|
||||||
});
|
|
||||||
if (!body.length || body[0].word.toLowerCase() !== word) return false;
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 404) return false;
|
if (err.status === 404) return false;
|
||||||
|
|||||||
@@ -106,18 +106,11 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
.send({
|
.send({
|
||||||
variables: {
|
variables: {
|
||||||
search: query,
|
search: query,
|
||||||
type: 'ANIME',
|
type: 'ANIME'
|
||||||
isAdult: Boolean(nsfw)
|
|
||||||
},
|
},
|
||||||
query: searchGraphQL
|
query: searchGraphQL
|
||||||
});
|
});
|
||||||
if (!body.data.anime.results.length) return null;
|
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;
|
return body.data.anime.results[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { WORDNIK_KEY } = process.env;
|
const { WEBSTER_KEY } = process.env;
|
||||||
|
|
||||||
module.exports = class DefineCommand extends Command {
|
module.exports = class DefineCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'define',
|
name: 'define',
|
||||||
aliases: ['dictionary', 'wordnik'],
|
aliases: ['dictionary', 'webster'],
|
||||||
group: 'search',
|
group: 'search',
|
||||||
memberName: 'define',
|
memberName: 'define',
|
||||||
description: 'Defines a word.',
|
description: 'Defines a word.',
|
||||||
credit: [
|
credit: [
|
||||||
{
|
{
|
||||||
name: 'Wordnik API',
|
name: 'Merriam-Webster\'s Collegiate® Dictionary',
|
||||||
url: 'https://developer.wordnik.com/'
|
url: 'https://dictionaryapi.com/products/api-collegiate-dictionary'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
@@ -31,18 +31,13 @@ module.exports = class DefineCommand extends Command {
|
|||||||
async run(msg, { word }) {
|
async run(msg, { word }) {
|
||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`http://api.wordnik.com/v4/word.json/${word}/definitions`)
|
.get(`https://www.dictionaryapi.com/api/v3/references/collegiate/json/${word}`)
|
||||||
.query({
|
.query({ key: WEBSTER_KEY });
|
||||||
limit: 1,
|
|
||||||
includeRelated: false,
|
|
||||||
useCanonical: true,
|
|
||||||
api_key: WORDNIK_KEY
|
|
||||||
});
|
|
||||||
if (!body.length) return msg.say('Could not find any results.');
|
if (!body.length) return msg.say('Could not find any results.');
|
||||||
const data = body[0];
|
const data = body[0];
|
||||||
return msg.say(stripIndents`
|
return msg.say(stripIndents`
|
||||||
**${data.word}**
|
**${data.stems[0]}** (${data.fl})
|
||||||
(${data.partOfSpeech || 'unknown'}) ${data.text}
|
${data.shortdef.map((definition, i) => `(${i + 1}) ${definition}`).join('\n')}
|
||||||
`);
|
`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ module.exports = class MangaCommand extends Command {
|
|||||||
.send({
|
.send({
|
||||||
variables: {
|
variables: {
|
||||||
search: query,
|
search: query,
|
||||||
type: 'MANGA',
|
type: 'MANGA'
|
||||||
isAdult: Boolean(nsfw)
|
|
||||||
},
|
},
|
||||||
query: searchGraphQL
|
query: searchGraphQL
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "103.0.4",
|
"version": "104.0.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user