commit
This commit is contained in:
parent
614b7afc08
commit
36a0e6a872
2 changed files with 19 additions and 11 deletions
29
app.js
29
app.js
|
@ -154,17 +154,26 @@ client.on('interactionCreate', async interaction => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
|
|
||||||
if (interaction.commandName === 'gptrequest') {
|
if (interaction.commandName === 'gptrequest') {
|
||||||
answerQuestion(interaction.options.get('question').value).then((res) => {
|
interaction.deferReply();
|
||||||
const embed = new discord.EmbedBuilder()
|
|
||||||
.setColor(0xFABBDE)
|
|
||||||
.setAuthor({ name : "Reply to : " + interaction.member.user.username, iconURL : "https://cdn.discordapp.com/avatars/"+interaction.member.user.id+"/"+interaction.member.user.avatar+".jpeg"})
|
|
||||||
.setTitle("Question : " + interaction.options.get('question').value)
|
|
||||||
.setDescription(res.data.choices[0].message.content)
|
|
||||||
.setFooter({ text : "Powered by OpenAI https://www.openai.com/", iconURL : "https://seeklogo.com/images/O/open-ai-logo-8B9BFEDC26-seeklogo.com.png" });
|
|
||||||
|
|
||||||
console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value);
|
answerQuestion(interaction.options.get('question').value).then((res) => {
|
||||||
addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value);
|
if (res.data.choices[0].message.content.length > 4096) {
|
||||||
interaction.reply({ embeds : [embed] });
|
interaction.reply(res.data.choices[0].message.content.lenght);
|
||||||
|
addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value);
|
||||||
|
console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
const embed = new discord.EmbedBuilder()
|
||||||
|
.setColor(0xFABBDE)
|
||||||
|
.setAuthor({ name : "Reply to : " + interaction.member.user.username, iconURL : "https://cdn.discordapp.com/avatars/"+interaction.member.user.id+"/"+interaction.member.user.avatar+".jpeg"})
|
||||||
|
.setTitle("Question : " + interaction.options.get('question').value)
|
||||||
|
.setDescription(res.data.choices[0].message.content)
|
||||||
|
.setFooter({ text : "Powered by OpenAI https://www.openai.com/", iconURL : "https://seeklogo.com/images/O/open-ai-logo-8B9BFEDC26-seeklogo.com.png" });
|
||||||
|
|
||||||
|
console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value);
|
||||||
|
addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value);
|
||||||
|
interaction.editReply({ embeds : [embed] });
|
||||||
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
addToLogs(err);
|
addToLogs(err);
|
||||||
|
|
|
@ -25,7 +25,6 @@ async function answerQuestion(query) {
|
||||||
response = await openai.createChatCompletion({
|
response = await openai.createChatCompletion({
|
||||||
model: "gpt-3.5-turbo",
|
model: "gpt-3.5-turbo",
|
||||||
messages: [{ "role" : "user", "content" : query}],
|
messages: [{ "role" : "user", "content" : query}],
|
||||||
max_tokens: 500,
|
|
||||||
temperature: 0.9,
|
temperature: 0.9,
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue