Adding Dictionary
This commit is contained in:
parent
c394af15d3
commit
42e7a234b3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.env
|
.env
|
||||||
node_modules
|
node_modules
|
||||||
images
|
images
|
||||||
|
audio
|
||||||
|
88
commands/untils/dictionary.js
Normal file
88
commands/untils/dictionary.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
const {
|
||||||
|
EmbedBuilder
|
||||||
|
} = require('discord.js');
|
||||||
|
const {
|
||||||
|
AttachmentBuilder
|
||||||
|
} = require('discord.js');
|
||||||
|
var download = require('download-file')
|
||||||
|
|
||||||
|
var unirest = require('unirest');
|
||||||
|
let meaningsArray = []
|
||||||
|
module.exports = {
|
||||||
|
name: "dictionary",
|
||||||
|
description: "Returns information about a word",
|
||||||
|
options: [{
|
||||||
|
"name": "word",
|
||||||
|
"description": "The data you would like inside of the QR",
|
||||||
|
"required": true,
|
||||||
|
"type": 3 // 6 is type USER
|
||||||
|
}],
|
||||||
|
run: async (client, interaction) => {
|
||||||
|
let rand = Math.floor(Math.random() * 99999).toString();
|
||||||
|
let word = interaction.options._hoistedOptions[0].value
|
||||||
|
|
||||||
|
unirest
|
||||||
|
.get('https://api.dictionaryapi.dev/api/v2/entries/en/' + word)
|
||||||
|
.headers({
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
let data = response.body[0]
|
||||||
|
let audio = data.phonetics[0].audio
|
||||||
|
let phonetic = data.phonetics[1].text
|
||||||
|
|
||||||
|
if (!audio) {
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Results for " + word + ": " + phonetic)
|
||||||
|
.addFields(meaningsArray)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({
|
||||||
|
text: `Requested by ${interaction.user.tag}`,
|
||||||
|
iconURL: `${interaction.user.displayAvatarURL()}`
|
||||||
|
});
|
||||||
|
interaction.editReply({
|
||||||
|
embeds: [embed]
|
||||||
|
});
|
||||||
|
rand = Math.floor(Math.random() * 99999).toString();
|
||||||
|
} else {
|
||||||
|
// Options for Audio Download
|
||||||
|
var options = {
|
||||||
|
directory: "./audio/",
|
||||||
|
filename: rand + ".mp3"
|
||||||
|
}
|
||||||
|
|
||||||
|
download(audio, options, function(err) {
|
||||||
|
if (err) throw err
|
||||||
|
console.log("audio downloaded")
|
||||||
|
console.log(response.body)
|
||||||
|
data.meanings.forEach(wordData => {
|
||||||
|
meaningsArray.push({
|
||||||
|
"name": wordData.partOfSpeech,
|
||||||
|
"value": wordData.definitions[0].definition
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const file = new AttachmentBuilder('./audio/' + rand + ".mp3");
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Results for " + word + ": " + phonetic)
|
||||||
|
.addFields(meaningsArray)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({
|
||||||
|
text: `Requested by ${interaction.user.tag}`,
|
||||||
|
iconURL: `${interaction.user.displayAvatarURL()}`
|
||||||
|
});
|
||||||
|
interaction.editReply({
|
||||||
|
embeds: [embed],
|
||||||
|
files: [file]
|
||||||
|
});
|
||||||
|
rand = Math.floor(Math.random() * 99999).toString();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
@ -36,6 +36,7 @@ module.exports = {
|
|||||||
url: 'attachment://discordjs.png',
|
url: 'attachment://discordjs.png',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor("#FF0000")
|
.setColor("#FF0000")
|
||||||
.setTitle("Your Generated QR Code")
|
.setTitle("Your Generated QR Code")
|
||||||
@ -46,7 +47,5 @@ module.exports = {
|
|||||||
interaction.editReply({ embeds: [embed], files: [file] });
|
interaction.editReply({ embeds: [embed], files: [file] });
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
48
package-lock.json
generated
48
package-lock.json
generated
@ -12,6 +12,7 @@
|
|||||||
"awesome-qr": "^2.1.5-rc.0",
|
"awesome-qr": "^2.1.5-rc.0",
|
||||||
"discord.js": "^14.0.3",
|
"discord.js": "^14.0.3",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
|
"download-file": "^0.1.5",
|
||||||
"give-me-a-joke": "^0.5.1",
|
"give-me-a-joke": "^0.5.1",
|
||||||
"glob": "^7.2.0",
|
"glob": "^7.2.0",
|
||||||
"is-not-defined": "^1.0.1",
|
"is-not-defined": "^1.0.1",
|
||||||
@ -467,6 +468,25 @@
|
|||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/download-file": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/download-file/-/download-file-0.1.5.tgz",
|
||||||
|
"integrity": "sha512-cTeC3HGeUdoxKmlWhcNwrCI19kb+WVcJBif1quxIeGmC91FkJzBQuHiQm25uOawV3t33JPthA6yl+f84ofn8UQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"mkdirp": "^0.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/download-file/node_modules/mkdirp": {
|
||||||
|
"version": "0.5.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||||
|
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||||
|
"dependencies": {
|
||||||
|
"minimist": "^1.2.6"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"mkdirp": "bin/cmd.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ecc-jsbn": {
|
"node_modules/ecc-jsbn": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
||||||
@ -873,6 +893,11 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/minimist": {
|
||||||
|
"version": "1.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||||
|
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
||||||
|
},
|
||||||
"node_modules/minipass": {
|
"node_modules/minipass": {
|
||||||
"version": "3.3.4",
|
"version": "3.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
|
||||||
@ -1839,6 +1864,24 @@
|
|||||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.2.tgz",
|
||||||
"integrity": "sha512-JvpYKUmzQhYoIFgK2MOnF3bciIZoItIIoryihy0rIA+H4Jy0FmgyKYAHCTN98P5ybGSJcIFbh6QKeJdtZd1qhA=="
|
"integrity": "sha512-JvpYKUmzQhYoIFgK2MOnF3bciIZoItIIoryihy0rIA+H4Jy0FmgyKYAHCTN98P5ybGSJcIFbh6QKeJdtZd1qhA=="
|
||||||
},
|
},
|
||||||
|
"download-file": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/download-file/-/download-file-0.1.5.tgz",
|
||||||
|
"integrity": "sha512-cTeC3HGeUdoxKmlWhcNwrCI19kb+WVcJBif1quxIeGmC91FkJzBQuHiQm25uOawV3t33JPthA6yl+f84ofn8UQ==",
|
||||||
|
"requires": {
|
||||||
|
"mkdirp": "^0.5.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"mkdirp": {
|
||||||
|
"version": "0.5.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||||
|
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||||
|
"requires": {
|
||||||
|
"minimist": "^1.2.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ecc-jsbn": {
|
"ecc-jsbn": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
||||||
@ -2139,6 +2182,11 @@
|
|||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"minimist": {
|
||||||
|
"version": "1.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||||
|
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
||||||
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "3.3.4",
|
"version": "3.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"awesome-qr": "^2.1.5-rc.0",
|
"awesome-qr": "^2.1.5-rc.0",
|
||||||
"discord.js": "^14.0.3",
|
"discord.js": "^14.0.3",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
|
"download-file": "^0.1.5",
|
||||||
"give-me-a-joke": "^0.5.1",
|
"give-me-a-joke": "^0.5.1",
|
||||||
"glob": "^7.2.0",
|
"glob": "^7.2.0",
|
||||||
"is-not-defined": "^1.0.1",
|
"is-not-defined": "^1.0.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user