error checking for dictionary
This commit is contained in:
parent
42e7a234b3
commit
21d8446383
@ -5,9 +5,11 @@ const {
|
||||
AttachmentBuilder
|
||||
} = require('discord.js');
|
||||
var download = require('download-file')
|
||||
|
||||
const isNotDefined = require("is-not-defined");
|
||||
let phonetic
|
||||
var unirest = require('unirest');
|
||||
let meaningsArray = []
|
||||
|
||||
module.exports = {
|
||||
name: "dictionary",
|
||||
description: "Returns information about a word",
|
||||
@ -28,10 +30,22 @@ module.exports = {
|
||||
'Content-Type': 'application/json',
|
||||
})
|
||||
.then((response) => {
|
||||
let data = response.body[0]
|
||||
let audio = data.phonetics[0].audio
|
||||
let phonetic = data.phonetics[1].text
|
||||
let data = response.body[0]
|
||||
|
||||
if (isNotDefined(data)){
|
||||
|
||||
return interaction.editReply("Sorry, nothing was found!")
|
||||
}
|
||||
|
||||
|
||||
if (isNotDefined(data.phonetics[1])){
|
||||
phonetic = ""
|
||||
} else {
|
||||
phonetic = data.phonetics[1].text
|
||||
|
||||
}
|
||||
|
||||
let audio = data.phonetics[0].audio
|
||||
if (!audio) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor("#FF0000")
|
||||
|
Loading…
Reference in New Issue
Block a user