#Api not replying

18 messages · Page 1 of 1 (latest)

main comet
#
bot.command({
  name:"ask", 
  code:`$djsEval[
  const Discord = require("discord.js");
const axios = require("axios");

async function respondToMessage(msg) {
  const response = await axios.post("https://api.openai.com/v1/engines/davinci/jobs", [{
    prompt: msg.message,
    max_tokens: 100,
    n: 1,
    stop: null,
    temperature: 0.5,
  }], {
    headers: {
      "Authorization": "SECRET CODE"
    }
  });

  msg.reply(response.data.choices[0].text);
}
;
;yes]`})

I have this aoi.js code but api doesn't send reply. I tried the code in normal discord.js but doesn't work too.

umbral plank
#

Also if you're using Node, why don't you use the API wrapper?

umbral plank
main comet
#

This library has discord.js eval code

umbral plank
#

But it's like in a string?

#

Why don't you use regular Discord.js?

main comet
#

undefined means nothing

#

because Bot send nothing

main comet
umbral plank
#

It's not the same syntax. Please take a look at the API reference.

main comet
umbral plank
#

Check out the the API reference, the /completions endpoint as documentation