Compare commits

..

2 Commits

Author SHA1 Message Date
Raven Scott
2718e8a38c adding tinygrad recognize 2023-02-21 04:41:11 +02:00
Raven Scott
99d28a3106 adding tinygrad recognize 2023-02-21 04:40:49 +02:00
3 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,37 @@
const { EmbedBuilder } = require('discord.js');
const cmd = require('cmd-promise')
var fs = require('fs');
module.exports = {
name: "recognize",
description: "recognize an object within an image using TinyGrad",
options: [{
"name": "image",
"description": "A 3 layer jpg",
"required": true,
"type": 11 // 6 is type USER
}],
run: async (client, interaction) => {
let rand = Math.floor(Math.random() * 99999999999999);
fileURL = interaction.options._hoistedOptions[0].attachment.url
cmd(`wget -O images/${rand}.jpg ${fileURL} && recognize images/${rand}.jpg`).then(out => {
(async () => {
await interaction.editReply({
files: [`images/${rand}.jpg`],
content: out.stdout
});
fs.unlinkSync(`images/${rand}.jpg`);
})();
}).catch(err => {
(async () => {
await interaction.editReply({
content: "There was an error, try another image."
});
fs.unlinkSync(`images/${rand}.jpg`);
})();
})
},
};

11
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"awesome-qr": "^2.1.5-rc.0",
"cmd-promise": "^1.2.0",
"discord.js": "^14.0.3",
"dotenv": "^16.0.0",
"download-file": "^0.1.5",
@ -360,6 +361,11 @@
"node": ">=10"
}
},
"node_modules/cmd-promise": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/cmd-promise/-/cmd-promise-1.2.0.tgz",
"integrity": "sha512-6lxSMygXwx7PPoOsK4k41DFHXeF/bsu4q4MyPL9MQkRHFzxiLqkgWl0FfoJV0w3VOo8AvCDzPLnCMgp4DB0SfQ=="
},
"node_modules/color-support": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
@ -1889,6 +1895,11 @@
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="
},
"cmd-promise": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/cmd-promise/-/cmd-promise-1.2.0.tgz",
"integrity": "sha512-6lxSMygXwx7PPoOsK4k41DFHXeF/bsu4q4MyPL9MQkRHFzxiLqkgWl0FfoJV0w3VOo8AvCDzPLnCMgp4DB0SfQ=="
},
"color-support": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",

View File

@ -12,6 +12,7 @@
"license": "ISC",
"dependencies": {
"awesome-qr": "^2.1.5-rc.0",
"cmd-promise": "^1.2.0",
"discord.js": "^14.0.3",
"dotenv": "^16.0.0",
"download-file": "^0.1.5",