From 22da662dc3958ef1dbc47a1d13f0896fadb7e72d Mon Sep 17 00:00:00 2001 From: Skillz Date: Wed, 2 Sep 2020 01:01:51 -0400 Subject: [PATCH] fix guild fetch members result on large guilds --- egg.yml | 2 +- src/handlers/guild.ts | 5 +++-- src/module/shardingManager.ts | 6 +----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/egg.yml b/egg.yml index 011900d9d..534ca8dff 100644 --- a/egg.yml +++ b/egg.yml @@ -2,7 +2,7 @@ name: Discordeno description: >- Discord Deno TypeScript API library wrapper(Officially vetted library by Discord Team) https://discordeno.netlify.app -version: 8.4.1 +version: 8.4.3 stable: true files: - ./src/**/* diff --git a/src/handlers/guild.ts b/src/handlers/guild.ts index a904dd25c..d3ee3f375 100644 --- a/src/handlers/guild.ts +++ b/src/handlers/guild.ts @@ -36,8 +36,9 @@ import { identifyPayload } from "../module/client.ts"; import { requestAllMembers } from "../module/shardingManager.ts"; import { MemberCreatePayload } from "../types/member.ts"; import { cache } from "../utils/cache.ts"; -import { createMember } from "../structures/member.ts"; +import { createMember, Member } from "../structures/member.ts"; import { urlToBase64 } from "../utils/utils.ts"; +import { Collection } from "../utils/collection.ts"; /** Gets an array of all the channels ids that are the children of this category. */ export function categoryChildrenIDs(guild: Guild, id: string) { @@ -210,7 +211,7 @@ export async function getMembersByQuery( return new Promise((resolve) => { requestAllMembers(guild, resolve, { query: name, limit }); - }); + }) as Promise>; } /** Create an emoji in the server. Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code. If a URL is provided to the image parameter, Discordeno will automatically convert it to a base64 string internally. */ diff --git a/src/module/shardingManager.ts b/src/module/shardingManager.ts index c3a283f01..7ce276628 100644 --- a/src/module/shardingManager.ts +++ b/src/module/shardingManager.ts @@ -372,11 +372,7 @@ export async function handleDiscordPayload( if (options.chunk_index + 1 === options.chunk_count) { fetchAllMembersProcessingRequests.delete(options.nonce); - resolve( - options.members.map((member) => - guild.members.get(member.user.id) - ), - ); + resolve(guild.members); } } }