mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-08 15:19:14 +02:00
Remove thesaurus, reverse dictionary
This commit is contained in:
@@ -29,6 +29,7 @@ module.exports = class DictionaryCommand extends Command {
|
||||
.query({
|
||||
limit: 1,
|
||||
includeRelated: false,
|
||||
useCanonical: true,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
module.exports = class ReverseDictionaryCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'reverse-dictionary',
|
||||
aliases: ['reverse-define', 'wordnik-reverse-define', 'wordnik-reverse-dictionary'],
|
||||
group: 'search',
|
||||
memberName: 'reverse-dictionary',
|
||||
description: 'Responds with the closest word for a given definition.',
|
||||
args: [
|
||||
{
|
||||
key: 'definition',
|
||||
prompt: 'What definition would you like to look up?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { definition }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.wordnik.com/v4/words.json/reverseDictionary')
|
||||
.query({
|
||||
query: definition,
|
||||
limit: 1,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.results) return msg.say('Could not find any results.');
|
||||
const data = body.results[0];
|
||||
return msg.say(stripIndents`
|
||||
**${data.word}**
|
||||
${data.text}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,46 +0,0 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
module.exports = class ThesaurusCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'thesaurus',
|
||||
aliases: ['synonym', 'antonym', 'wordnik-thesaurus'],
|
||||
group: 'search',
|
||||
memberName: 'thesaurus',
|
||||
description: 'Responds with the synonyms and antonyms of a word.',
|
||||
args: [
|
||||
{
|
||||
key: 'word',
|
||||
prompt: 'What word would you like to look up?',
|
||||
type: 'string',
|
||||
parse: word => encodeURIComponent(word)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.wordnik.com/v4/word.json/${word}/relatedWords`)
|
||||
.query({
|
||||
relationshipTypes: 'synonym,antonym',
|
||||
limitPerRelationshipType: 5,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
const synonyms = body.find(words => words.relationshipType === 'synonym');
|
||||
const antonyms = body.find(words => words.relationshipType === 'antonym');
|
||||
return msg.say(stripIndents`
|
||||
**${word}**
|
||||
__Synonyms:__ ${synonyms ? synonyms.words.join(', ') : '???'}
|
||||
__Antonyms:__ ${antonyms ? antonyms.words.join(', ') : '???'}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "54.3.0",
|
||||
"version": "55.0.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "XiaoBot.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user