Estal
Estal
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Estal on 12/7/2023 in #djs-questions
Unknown Interaction. Not sure what the cause is
ah; yeah; sometimes it does take more than three seconds, so tells me that that's probably what I need to read up on. Thanks @Danial 🐝
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 12/7/2023 in #djs-questions
Unknown Interaction. Not sure what the cause is
And the code to actually process the event is
async execute(interaction) {
if (!interaction.isCommand()) return;

const aiQuestion = interaction.options.getString('question');

const openai = new OpenAI({ apiKey: openaiApiKey, engine: gptEngine });

try {
const response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: aiQuestion }],
});
const question = `${interaction.user.displayName} asked ${aiQuestion}`;
const answer = response.choices[0].message.content;
console.log(answer);

if (interaction.deferred) {
await interaction.followUp(`${question}\n\n${answer}`);
} else {
await interaction.reply(`${question}\n\n${answer}`);
}

} catch (error) {
await interaction.reply({
content: 'Sorry, I encountered an error while processing your request.',
ephemeral: true,
});
console.error('Error communicating with GPT-3.5:', error.message);
}
}
async execute(interaction) {
if (!interaction.isCommand()) return;

const aiQuestion = interaction.options.getString('question');

const openai = new OpenAI({ apiKey: openaiApiKey, engine: gptEngine });

try {
const response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: aiQuestion }],
});
const question = `${interaction.user.displayName} asked ${aiQuestion}`;
const answer = response.choices[0].message.content;
console.log(answer);

if (interaction.deferred) {
await interaction.followUp(`${question}\n\n${answer}`);
} else {
await interaction.reply(`${question}\n\n${answer}`);
}

} catch (error) {
await interaction.reply({
content: 'Sorry, I encountered an error while processing your request.',
ephemeral: true,
});
console.error('Error communicating with GPT-3.5:', error.message);
}
}
What really stumps me is that I'll get the error 1 time, but another the command works fine and the console.log always returns the answer just not sure if I'm handling the interaction wrong or what's going on there.
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 12/7/2023 in #djs-questions
Unknown Interaction. Not sure what the cause is
Part two..
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 12/5/2023 in #djs-questions
Global / Commands
Interesting. I’ll have to see what I messed up after work tomorrow. Thanks!
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 11/14/2023 in #djs-questions
First Example from the site doesn't work.
Fair enough. Was looking at the docs from 14.14.1; it's been a few years since I messed around with js really, but just changing the extension to mjs from js has helped
4 replies