sertchan / Discord-Scraper

Discord guild members pfp, username and id scraper.
https://i.imgur.com/YlSpFmr.png
MIT License
31 stars 7 forks source link

Members didn't arrive in time #13

Closed leandrocunha526 closed 1 year ago

leandrocunha526 commented 1 year ago

Hello, you can verify solution about this, please? Problem with library in use (i think) and not with code. I try get 100+ members. Thanks for this project. Return: C:\Users\leand\git\Discord-Scraper\node_modules\discord.js-selfbot-v13\src\managers\GuildMemberManager.js:641 reject(new Error('GUILD_MEMBERS_TIMEOUT')); ^

Error [GUILD_MEMBERS_TIMEOUT]: Members didn't arrive in time. at Timeout._onTimeout (C:\Users\leand\git\Discord-Scraper\node_modules\discord.js-selfbot-v13\src\managers\GuildMemberManage r.js:641:16) at listOnTimeout (node:internal/timers:559:17) at processTimers (node:internal/timers:502:7) {

} error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

sertchan commented 1 year ago

looks like problem with api you can update module or just try with another account

leandrocunha526 commented 1 year ago

I did that and it didn't solve the problem.

sertchan commented 1 year ago

i don't have any idea... it's not related with code so i cant do anything about it

leandrocunha526 commented 1 year ago

Discord.js-selfbot-v13 was having issues with this and it could be a regression. I've opened an issue and leave this issue it open until I get answers about it.

sertchan commented 1 year ago

okay

leandrocunha526 commented 1 year ago

I believe that something has changed, the maintainer had the documentation read and some updates occurred in the way of implementing the Guild Member Manager. Where added the following code:

 * Fetches multiple members from the guild.
   * @param {GuildTextChannelResolvable} channel The channel to get members from (Members has VIEW_CHANNEL permission)
   * @param {number} [offset=0] Start index of the members to get
   * @param {number} [time=10e3] Timeout for receipt of members
   * @returns {Collection<Snowflake, GuildMember>} Members in the guild
   */
  fetchMemberList(channel, offset = 0, time = 10_000) {
    const channel_ = this.guild.channels.resolve(channel);
    if (!channel_?.isText()) throw new TypeError('INVALID_TYPE', 'channel', 'GuildTextChannelResolvable');
    if (typeof offset !== 'number') throw new TypeError('INVALID_TYPE', 'offset', 'Number');
    if (typeof time !== 'number') throw new TypeError('INVALID_TYPE', 'time', 'Number');
    return new Promise((resolve, reject) => {
      const default_ = [[0, 99]];
      const fetchedMembers = new Collection();
      if (offset === 0) {
        default_.push([100, 199]);
      } else {
        default_.push([offset, offset + 99], [offset + 100, offset + 199]);
      }
      this.guild.shard.send({
        op: Opcodes.LAZY_REQUEST,
        d: {
          guild_id: this.guild.id,
          typing: true,
          threads: true,
          activities: true,
          channels: {
            [channel_.id]: default_,
          },
          thread_member_lists: [],
          members: [],
        },
      });
      const handler = (members, guild, type, raw) => {
        timeout.refresh();
        if (guild.id !== this.guild.id) return;
        if (type == 'INVALIDATE' && offset > 100) {
          this.client.removeListener(Events.GUILD_MEMBER_LIST_UPDATE, handler);
          this.client.decrementMaxListeners();
          reject(new Error('INVALIDATE_MEMBER', raw.ops[0].range));
        } else {
          for (const member of members.values()) {
            fetchedMembers.set(member.id, member);
          }
          clearTimeout(timeout);
          this.client.removeListener(Events.GUILD_MEMBER_LIST_UPDATE, handler);
          this.client.decrementMaxListeners();
          resolve(fetchedMembers);
        }
      };
      const timeout = setTimeout(() => {
        this.client.removeListener(Events.GUILD_MEMBER_LIST_UPDATE, handler);
        this.client.decrementMaxListeners();
        reject(new Error('GUILD_MEMBERS_TIMEOUT'));
      }, time).unref();
      this.client.incrementMaxListeners();
      this.client.on(Events.GUILD_MEMBER_LIST_UPDATE, handler);
    });
  }

https://github.com/aiko-chan-ai/discord.js-selfbot-v13/commit/bbdf2943308b0544c6feb20eafa2093956a762a8

sertchan commented 1 year ago

can you try old version of api?

leandrocunha526 commented 1 year ago

I still have timer issues, in 2.3.3, 2.4.7 and 2.4.15. I tried some changes and without success.

sertchan commented 1 year ago

so do we know what's wrong?

leandrocunha526 commented 1 year ago

I still need to study the documentation and code in more detail.

sertchan commented 1 year ago

👍🏻

anthonyserrano34 commented 1 year ago

Same issue here.

sertchan commented 1 year ago

Intresting. Like we said problem probably from the api so we cannot do anything about it.