jlyons210 / discord-bot-ol-bootsie

Ol' Bootsie is a highly configurable Discord bot that interfaces with the OpenAI API, written for Node.js in Typescript.
The Unlicense
2 stars 2 forks source link

Process crashes posting to Discord if OpenAI response is empty #7

Closed jlyons210 closed 1 year ago

jlyons210 commented 1 year ago
Mon, 17 Apr 2023 18:26:19 GMT - INFO - New OpenAI prompt: It is going alright, just working so far...how about yours?
Mon, 17 Apr 2023 18:26:19 GMT - INFO - OpenAI response:
/app/node_modules/@discordjs/rest/dist/index.js:640
      throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
            ^

DiscordAPIError[50006]: Cannot send an empty message
    at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:640:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:1021:23)
    at async SequentialHandler.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:862:14)
    at async REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1387:22)
    at async TextChannel.send (/app/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:157:15) {
  requestBody: {
    files: [],
    json: {
      content: '',
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined
    }
  },
  rawError: { message: 'Cannot send an empty message', code: 50006 },
  code: 50006,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/1078799791892471818/messages'
}

Node.js v18.16.0
jlyons210 commented 1 year ago

Fixed in 0.3.1 dev branch.