aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
746 stars 160 forks source link

Cannot set properties of undefined (setting 'keepAlive') #1220

Closed Helutu closed 1 month ago

Helutu commented 1 month ago

Which package has the bugs?

The core library

Issue description

[7/18/2024, 11:56:19 AM] m.sanderv.5155: Error joining guild because of Cannot set properties of undefined (setting 'keepAlive'): 5pDUQ2q6rj HTTPError [TypeError]: Cannot set properties of undefined (setting 'keepAlive') at RequestHandler.execute (/home/ubuntu/spark-ad-bot/api/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:213:15) at RequestHandler.execute (/home/ubuntu/spark-ad-bot/api/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:217:19) at RequestHandler.push (/home/ubuntu/spark-ad-bot/api/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:63:25) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Client.fetchInvite (/home/ubuntu/spark-ad-bot/api/node_modules/discord.js-selfbot-v13/src/client/Client.js:373:18) { code: 500, method: 'get', path: '/invites/5pDUQ2q6rj?with_counts=true&with_expiration=true', requestData: { json: undefined, files: [], headers: undefined } }

In the latest installed version, I always get this thing, and if I install an older version I get "Unknown Message". What can I do ?

Code sample

constructor(token: string) {
    this.client = new Client({
      http: {
        agent: proxy,
      },
      ws: {
        agent: proxy,
      },
      captchaSolver: function (captcha, UA) {
        return solver
          .hcaptcha({
            pageurl: "discord.com",
            sitekey: captcha.captcha_sitekey,
            invisible: 1,
            userAgent: UA,
            data: captcha.captcha_rqdata,
          })
          .then((res) => res.data);
      },
      captchaRetryLimit: 3,
    });

    this.client.token = token;
  }

  async joinGuild(invite: string) {
    const checkGuild = await this.client.fetchInvite(invite);

    if (!checkGuild) return "invalidinvite";

    try {
      await this.client.acceptInvite(invite).then((res: any) => {
        console.log('invite', res)
      })
      return "success";
    } catch (err: any) {
      switch (err.code) {
        case 50013:
          return "missingpermissions";
        case 50001:
          return "missingaccess";
        case 40007:
          return "banned";
        case 40002:
          return "unverified";
        default:
          console.log(`[${new Date().toLocaleString()}] ${this.client.user?.username}: An error occurred: ${err.message}`);
          return "error";
      }
    }
  }

Package version

discord.js-selfbot-v13@3.2.2

Node.js version

22.5.0

Operating system

Windows/Linux

Priority this issue should have

High (immediate attention needed)

Checklist

Additional Information

No response

aiko-chan-ai commented 1 month ago

what proxy

Helutu commented 1 month ago

I have iproyal and rain, and even without proxy it's the same

Helutu commented 1 month ago
const proxyLink = 'http://...:...@geo.iproyal.com:12321'
const httpAgent = new HttpsProxyAgent(proxyLink)
const wsAgent = new HttpsProxyAgent(proxyLink)

const client = new Client({
  captchaSolver: async function (captcha, UA) {
    console.log("[INFO]: Attempting to solve hCaptcha");
    const solveCaptchaUrl = "https://api.capmonster.cloud/createTask";
    const getCaptchaResultUrl = "https://api.capmonster.cloud/getTaskResult";

    const ApiKey = ""

  const captchaTask = {
    clientKey: ApiKey,
    task: {
      type: "HCaptchaTaskProxyless",
      websiteURL: "https://discord.com",
      websiteKey: captcha.captcha_sitekey,
      data: captcha.captcha_rqdata,
      isInvisible: true,
      userAgent: UA,
      fallbackToActualUA:true
    },
  };

    try {
      const taskResponse = await axios.post(solveCaptchaUrl, captchaTask);
      const taskId = taskResponse.data.taskId;

      let taskResult;
      do {
        await new Promise((r) => setTimeout(r, 2000));
        const resultResponse = await axios.post(getCaptchaResultUrl, {
          clientKey: ApiKey,
          taskId: taskId,
        });
        taskResult = resultResponse.data;
      } while (taskResult.status !== "ready");

      console.log(
        "[SUCCES] Captcha was solved with succes !"
      );

      return taskResult.solution.gRecaptchaResponse;
    } catch (err) {
      console.log("Error solving the captcha:");
      console.log(err);
    }
  },
  http: {
    headers: {
      "x-super-properties":
        "eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiRGlzY29yZCBDbGllbnQiLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfdmVyc2lvbiI6IjEuMC45MTQ4Iiwib3NfdmVyc2lvbiI6IjEwLjAuMTkwNDUiLCJvc19hcmNoIjoieDY0IiwiYXBwX2FyY2giOiJ4NjQiLCJzeXN0ZW1fbG9jYWxlIjoiZW4tVVMiLCJicm93c2VyX3VzZXJfYWdlbnQiOiJNb3ppbGxhLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBkaXNjb3JkLzEuMC45MTQ4IENocm9tZS8xMjAuMC42MDk5LjI5MSBFbGVjdHJvbi8yOC4yLjEwIFNhZmFyaS81MzcuMzYiLCJicm93c2VyX3ZlcnNpb24iOiIyOC4yLjEwIiwiY2xpZW50X2J1aWxkX251bWJlciI6Mjk5ODk5LCJuYXRpdmVfYnVpbGRfbnVtYmVyIjo0ODQ2OCwiY2xpZW50X2V2ZW50X3NvdXJjZSI6bnVsbCwiZGVzaWduX2lkIjowfQ==",
    },
    agent: httpAgent,
  },
  ws: {
    agent: wsAgent,
  },
  restRequestTimeout: 60 * 1000,
  restWsBridgeTimeout: 5 * 1000,
  captchaRetryLimit: 3,
});

And when I use this, somehow it doesn't connect to the proxy because I always get the error 429, and on version 3.1.3 it works very well.


Hit a 429 while executing a request.
    Global  : false
    Method  : get
    Path    : /invites/GKwmGp2fmW?with_counts=true&with_expiration=true
    Route   : /invites/GKwmGp2fmW
    Limit   : Infinity
    Timeout : 500ms
    Sublimit: 1948000ms
aiko-chan-ai commented 1 month ago

Why don't you try using the ProxyAgent library?

Helutu commented 1 month ago

Why don't you try using the ProxyAgent library?

import { ProxyAgent } from "proxy-agent";

const proxyLink = "http://aaaa:Aaaa@geo.iproyal.com:12321";

const proxyAgent = new ProxyAgent(proxyLink);

Argument of type '"http://aaaa:Aaaa@geo.iproyal.com:12321"' is not assignable to parameter of type 'ProxyAgentOptions | undefined'.ts(2345)

And if I use like this

const proxyAgent = new ProxyAgent({getProxyForUrl: (url) => proxyLink});

I get this error because I opened this issue: Cannot set properties of undefined (setting 'keepAlive')

aiko-chan-ai commented 1 month ago

Can you lend me a proxy to check through Discord via DMs?

Helutu commented 1 month ago

Can you lend me a proxy to check through Discord via DMs?

Sure, I gave you add: helutuu

aiko-chan-ai commented 1 month ago

added 👍

g3y commented 1 week ago

I'm having the same issue here, found no fix whatsoever all my proxies are working from webshare