mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 15:07:26 +02:00
add code command
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
const http = require("https");
|
||||
|
||||
module.exports = {
|
||||
name: 'code',
|
||||
aliases: [],
|
||||
description: 'Génére du code.',
|
||||
category: 'utils',
|
||||
emote: '📌',
|
||||
utilisation: 'code <lenguage> <prompt>',
|
||||
|
||||
async execute(message, args) {
|
||||
const lenguage = args[0]
|
||||
const prompt = args.slice(1).join(' ');
|
||||
const options = {
|
||||
"method": "POST",
|
||||
"hostname": "api.textcortex.com",
|
||||
"port": null,
|
||||
"path": "/v1/codes",
|
||||
"headers": {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer gAAAAABl8hnwXg-FXY1t5PNCTcEGvcN86UaaXycbse_6ZhdlEt_lBbkieBh3QTxjxu5ii1rs--YeoSu-GIh4GwLx2ADp5WtHX867wedEEkYji3kdInL-qgyeayGEODhUQyYd-x8XESZq"
|
||||
}
|
||||
};
|
||||
|
||||
const req = http.request(options, function (res) {
|
||||
const chunks = [];
|
||||
|
||||
res.on("data", function (chunk) {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
res.on("end", function () {
|
||||
const body = Buffer.concat(chunks);
|
||||
const response = JSON.parse(body.toString());
|
||||
if (response.status === "success") {
|
||||
const output = response.data.outputs[0].text;
|
||||
message.reply(`\`\`\`${lenguage}\n${output}\`\`\``);
|
||||
} else {
|
||||
console.log("Error: Request failed with API");
|
||||
message.reply("Erreur lors de l'execution de l'API.\n le premier parametre est le lengage de pregramation exemple : python, javascript, php, java...")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.write(JSON.stringify({
|
||||
max_tokens: 2048,
|
||||
mode: lenguage,
|
||||
model: 'icortex-1',
|
||||
n: 1,
|
||||
temperature: 0,
|
||||
text: prompt
|
||||
}));
|
||||
req.end();
|
||||
|
||||
}
|
||||
};
|
||||
+2
-1
@@ -174,5 +174,6 @@
|
||||
"setconfession": 3,
|
||||
"presetlog": 3,
|
||||
"blword": 3,
|
||||
"wiki": 3
|
||||
"wiki": 3,
|
||||
"code": 0
|
||||
}
|
||||
Reference in New Issue
Block a user