Bug Fix: Fixing Dictionary not loading on some words
This commit is contained in:
parent
d85912e80d
commit
47cb0dba9a
@ -31,12 +31,12 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
let data = response.body[0]
|
let data = response.body[0]
|
||||||
|
console.log(data.meanings)
|
||||||
if (isNotDefined(data)) {
|
if (isNotDefined(data)) {
|
||||||
return interaction.editReply("Sorry, nothing was found!")
|
return interaction.editReply("Sorry, nothing was found!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotDefined(data.phonetics[1])) {
|
if (isNotDefined(data.phonetics)) {
|
||||||
phonetic = ""
|
phonetic = ""
|
||||||
} else {
|
} else {
|
||||||
phonetic = data.phonetics[1].text
|
phonetic = data.phonetics[1].text
|
||||||
@ -44,6 +44,22 @@ module.exports = {
|
|||||||
|
|
||||||
let audio = data.phonetics[0].audio
|
let audio = data.phonetics[0].audio
|
||||||
if (!audio) {
|
if (!audio) {
|
||||||
|
|
||||||
|
data.meanings.forEach(wordData => {
|
||||||
|
|
||||||
|
if (wordData.definitions[0].example) {
|
||||||
|
meaningsArray.push({
|
||||||
|
"name": wordData.partOfSpeech,
|
||||||
|
"value": wordData.definitions[0].definition + "\nExample: " + wordData.definitions[0].example
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
meaningsArray.push({
|
||||||
|
"name": wordData.partOfSpeech,
|
||||||
|
"value": wordData.definitions[0].definition
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor("#FF0000")
|
.setColor("#FF0000")
|
||||||
.setTitle("Results for " + word + ": " + phonetic)
|
.setTitle("Results for " + word + ": " + phonetic)
|
||||||
@ -68,7 +84,7 @@ module.exports = {
|
|||||||
download(audio, options, function(err) {
|
download(audio, options, function(err) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log("audio downloaded")
|
console.log("audio downloaded")
|
||||||
console.log(response.body)
|
console.log(data.meanings)
|
||||||
data.meanings.forEach(wordData => {
|
data.meanings.forEach(wordData => {
|
||||||
|
|
||||||
if (wordData.definitions[0].example) {
|
if (wordData.definitions[0].example) {
|
||||||
@ -83,6 +99,7 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
const file = new AttachmentBuilder('./audio/' + rand + ".mp3");
|
const file = new AttachmentBuilder('./audio/' + rand + ".mp3");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user