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.commandName === 'gptrequest') {
|
||||
answerQuestion(interaction.options.get('question').value).then((res) => {
|
||||
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" });
|
||||
interaction.deferReply();
|
||||
|
||||
console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value);
|
||||
addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value);
|
||||
interaction.reply({ embeds : [embed] });
|
||||
answerQuestion(interaction.options.get('question').value).then((res) => {
|
||||
if (res.data.choices[0].message.content.length > 4096) {
|
||||
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) => {
|
||||
console.log(err);
|
||||
addToLogs(err);
|
||||
|
|
|
@ -25,7 +25,6 @@ async function answerQuestion(query) {
|
|||
response = await openai.createChatCompletion({
|
||||
model: "gpt-3.5-turbo",
|
||||
messages: [{ "role" : "user", "content" : query}],
|
||||
max_tokens: 500,
|
||||
temperature: 0.9,
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue