diff --git a/commands/untils/dictionary.js b/commands/untils/dictionary.js index 9c6fd69..0352e63 100644 --- a/commands/untils/dictionary.js +++ b/commands/untils/dictionary.js @@ -31,12 +31,12 @@ module.exports = { }) .then((response) => { let data = response.body[0] - + console.log(data.meanings) if (isNotDefined(data)) { return interaction.editReply("Sorry, nothing was found!") } - if (isNotDefined(data.phonetics[1])) { + if (isNotDefined(data.phonetics)) { phonetic = "" } else { phonetic = data.phonetics[1].text @@ -44,6 +44,22 @@ module.exports = { let audio = data.phonetics[0].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() .setColor("#FF0000") .setTitle("Results for " + word + ": " + phonetic) @@ -68,7 +84,7 @@ module.exports = { download(audio, options, function(err) { if (err) throw err console.log("audio downloaded") - console.log(response.body) + console.log(data.meanings) data.meanings.forEach(wordData => { if (wordData.definitions[0].example) { @@ -83,6 +99,7 @@ module.exports = { }) } }); + console.log(data) const file = new AttachmentBuilder('./audio/' + rand + ".mp3");