mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 02:15:10 +02:00
Fix some things
This commit is contained in:
@@ -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!`);
|
||||
|
||||
Reference in New Issue
Block a user