Adding examples to dictionary if one is provided

This commit is contained in:
Raven Scott 2022-09-25 06:15:26 -04:00
parent 34a842b707
commit d85912e80d

View File

@ -70,10 +70,18 @@ module.exports = {
console.log("audio downloaded") console.log("audio downloaded")
console.log(response.body) console.log(response.body)
data.meanings.forEach(wordData => { data.meanings.forEach(wordData => {
meaningsArray.push({
"name": wordData.partOfSpeech, if (wordData.definitions[0].example) {
"value": wordData.definitions[0].definition 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 file = new AttachmentBuilder('./audio/' + rand + ".mp3"); const file = new AttachmentBuilder('./audio/' + rand + ".mp3");