AdamT20054 / DJSCaptcha

A NPM module for Discord.js made to easily create CAPTCHAs to present to your Discord servers members.
https://www.npmjs.com/package/djscaptcha
GNU General Public License v3.0
13 stars 1 forks source link

Crashes when cant DM user[BUG] #15

Closed AdamT20054 closed 1 year ago

AdamT20054 commented 2 years ago

Describe the bug Bot crashes when trying to DM a user that it cant

To Reproduce Steps to reproduce the behavior:

  1. Make the bot DM a user it cant

Expected behavior It should try the fallback channel if provided, or just not send a captcha

Screenshots

throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
              ^

DiscordAPIError[50007]: Cannot send messages to this user
    at SequentialHandler.runRequest (C:\Users\Elijah\Desktop\bots\vf\node_modules@discordjs\rest\dist\index.js:659:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (C:\Users\Elijah\Desktop\bots\vf\node_modules@discordjs\rest\dist\index.js:458:14)
    at async REST.request (C:\Users\Elijah\Desktop\bots\vf\node_modules@discordjs\rest\dist\index.js:902:22)
    at async DMChannel.send (C:\Users\Elijah\Desktop\bots\vf\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:175:15)
    at async C:\Users\Elijah\Desktop\bots\vf\node_modules\djscaptcha\src\index.cjs:331:25
    at async handleAttempt (C:\Users\Elijah\Desktop\bots\vf\node_modules\djscaptcha\src\index.cjs:311:17)
    at async C:\Users\Elijah\Desktop\bots\vf\node_modules\djscaptcha\src\index.cjs:511:13
    at async Captcha.present (C:\Users\Elijah\Desktop\bots\vf\node_modules\djscaptcha\src\index.cjs:258:9) {
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [
        {
          title: '❌ You failed to solve the Captcha!!',
          description: "» <@741601107310018560>, you've failed to solve the Captcha, we know these can be hard sometimes.\n" +
            'Please rejoin the server if you want to try again!',
          timestamp: '2022-10-23T16:29:11.678Z',
          color: 13047061,
          thumbnail: {
            url: 'https://cdn.discordapp.com/icons/1025748794245132328/745b42c9a7d4a860380109928b799e35.webp'
          }
        }
      ],
      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 messages to this user', code: 50007 },
  code: 50007,
  status: 403,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/1033779135950110750/messages'
}
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days