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
1 changed files with 12 additions and 4 deletions

View File

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