my current code is
const { SlashCommandBuilder } = require('@discordjs/builders');
const openai = require('openai');
openai.apiKey = 'XX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
module.exports = {
data: new SlashCommandBuilder()
.setName('chat')
.setDescription('Chat with a chatbot')
.addStringOption(option => option.setName('prompt').setDescription('Prompt of the message').setRequired(true)),
async execute(interaction) {
const { options } = interaction;
const input = interaction.options.getString('prompt');
openai.completions.create({
model: 'davinci',
prompt: input,
max_tokens: 256,
n: 1,
stop: '\n',
temperature: 0.5,
}).then((gpt3Response) => {
const responseText = gpt3Response.data.text[0];
interaction.reply(responseText);
});
},
};
im getting the error
TypeError: Cannot read properties of undefined (reading 'completions')