Eccleria / ewibot

Discord bot for La Quête d'Ewilan server.
3 stars 0 forks source link

Polls - fix multiple issues #240

Closed Eccleria closed 1 year ago

Eccleria commented 1 year ago
file:///home/ewibot/ewibot/src/commands/polls/pollsCollectors.js:34
  for (const interaction of clientData.votes)
                                       ^

TypeError: Cannot read properties of undefined (reading 'votes')
    at Timeout.pollBufferLoop [as _onTimeout] (file:///home/ewibot/ewibot/src/commands/polls/pollsCollectors.js:34:40)
    at listOnTimeout (node:internal/timers:561:11)
    at processTimers (node:internal/timers:502:7)
components[0].components[2].emoji.name: Invalid emoji
    at RequestHandler.execute (/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async MessageManager.edit (/home/ewibot/ewibot/node_modules/discord.js/src/managers/MessageManager.js:132:15) {
  method: 'patch',
  path: '/channels/822132004581408828/messages/1136719598297829486',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [
        {
          title: 'Ecclé est-il un génial développeur ?',
          type: 'rich',
          description: "un sondage qu'il est important",
          url: null,
          timestamp: 2023-08-03T17:57:51.313Z,
          color: 1146986,
          fields: [ [Object], [Object], [Object] ],
          thumbnail: null,
          image: null,
          author: null,
          footer: { text: 'Vote unique | ⚙️ options', icon_url: undefined }
        }
      ],
      components: [
        {
          components: [ [Object], [Object], [Object], [Object] ],
          type: 1
        }
      ],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: 0,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined
    },
    files: []
  }
}
file:///home/ewibot/ewibot/src/commands/polls/pollsUtils.js:110
  const values = dbPoll.votes.map((obj) => obj.votes.length);
                        ^

TypeError: Cannot read properties of undefined (reading 'votes')
    at refreshPollFields (file:///home/ewibot/ewibot/src/commands/polls/pollsUtils.js:110:25)
    at stopPoll (file:///home/ewibot/ewibot/src/commands/polls/pollsUtils.js:175:21)
    at stopPollButtonAction (file:///home/ewibot/ewibot/src/commands/polls/pollsButton.js:80:9)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Eccleria commented 1 year ago
polls command
/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Invalid Form Body
components[0].components[0].options[2].label: Must be between 1 and 100 in length.
    at RequestHandler.execute (/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async InteractionWebhook.editMessage (/home/ewibot/ewibot/node_modules/discord.js/src/structures/Webhook.js:327:15)
    at async ButtonInteraction.editReply (/home/ewibot/ewibot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:150:21)
    at async interactionEditReply (file:///home/ewibot/ewibot/src/commands/polls/pollsUtils.js:63:5) {
  method: 'patch',
  path: '/webhooks/926909518963695737/aW50ZXJhY3Rpb246MTE1Nzk3ODc0MTA5MjQwMTE3MzpMOUhDTnNjcVVWUzFZMW1kMGpZaHI3SEdscklGV2tUaGpEZlY5MDN4cHlpNVNad2tQSGw5TGdZZWpabUMzRk9BTzRyR0RHd3ZZV2hsOFZBZmpjcjBSZnRLVzZlcGI3eEJrWnRkMFNsMjZDY3RwU0dSZmFPb09mMHZMRzB4SzN3Vw/messages/@original',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: [ { components: [ [Object] ], type: 1 } ],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: 64,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined
    },
    files: []
  }
}
Eccleria commented 1 year ago
polls command
/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Invalid Form Body
components[0].components[0].options[2].label: Must be between 1 and 100 in length.
    at RequestHandler.execute (/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/ewibot/ewibot/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async InteractionWebhook.editMessage (/home/ewibot/ewibot/node_modules/discord.js/src/structures/Webhook.js:327:15)
    at async ButtonInteraction.editReply (/home/ewibot/ewibot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:150:21)
    at async interactionEditReply (file:///home/ewibot/ewibot/src/commands/polls/pollsUtils.js:63:5) {
  method: 'patch',
  path: '/webhooks/926909518963695737/aW50ZXJhY3Rpb246MTE1Nzk3ODc0MTA5MjQwMTE3MzpMOUhDTnNjcVVWUzFZMW1kMGpZaHI3SEdscklGV2tUaGpEZlY5MDN4cHlpNVNad2tQSGw5TGdZZWpabUMzRk9BTzRyR0RHd3ZZV2hsOFZBZmpjcjBSZnRLVzZlcGI3eEJrWnRkMFNsMjZDY3RwU0dSZmFPb09mMHZMRzB4SzN3Vw/messages/@original',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: [ { components: [ [Object] ], type: 1 } ],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: 64,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined
    },
    files: []
  }
}

will be fixed in another PR