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

Hard crash in 0.10.1 `DiscordBot._probablyReactToMessage()` #68

Closed jlyons210 closed 1 year ago

jlyons210 commented 1 year ago

Error is not being caught correctly. Need to fix.

/usr/src/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[10014]: Unknown Emoji
    at handleErrors (/usr/src/app/node_modules/@discordjs/rest/dist/index.js:640:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/usr/src/app/node_modules/@discordjs/rest/dist/index.js:1021:23)
    at async SequentialHandler.queueRequest (/usr/src/app/node_modules/@discordjs/rest/dist/index.js:862:14)
    at async REST.request (/usr/src/app/node_modules/@discordjs/rest/dist/index.js:1387:22)
    at async MessageManager.react (/usr/src/app/node_modules/discord.js/src/managers/MessageManager.js:243:5)
    at async Message.react (/usr/src/app/node_modules/discord.js/src/structures/Message.js:792:5) {
  requestBody: { files: undefined, json: undefined },
  rawError: { message: 'Unknown Emoji', code: 10014 },
  code: 10014,
  status: 400,
  method: 'PUT',
  url: 'https://discord.com/api/v10/channels/1108786370702483496/messages/1113531767614361770/reactions/%20/@me'
}

Node.js v18.16.0
jlyons210 commented 1 year ago

Failable calls within a .forEach() block need to have a try/catch block within the .forEach() loop. Updated in DiscordBot._handleMessageCreate() and DiscordBot._probablyReactToMessage().