refactor: resolve promises (#515)

* Adding missing await and updating some deps

* Adding missing await and updating some deps

* Adding missing await and updating some deps

* Fix close code 4009 until deno fixes the issue: https://github.com/denoland/deno/pull/8776

* Fix heartbeating

* Add await for the requestGuildMembers in requestAllMembers

* Change body && body.file to body?.file

* Fix lint #1

* Change body && body.file to body?.file

* Fix lint

* Deno lint

* Update request.ts

* Fix deno lint error

* Update src/ws/shard_manager.ts

Co-authored-by: ayntee <ayyantee@gmail.com>

* Fix fetchMembers

* Fix getMembersByQuery

* Try to fix RequestMembersQueue processing

* Deno lint

* Fix requestGuildMembers

* Fix requestGuildMembers

* Fix requestAllMembers

* Undo useless changes

* Fix merge conflict

* Fix merge conflict

* Change for loop to Promise.all

* Deno fmt

Co-authored-by: ayntee <ayyantee@gmail.com>
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
TriForMine
2021-02-15 08:19:45 +01:00
committed by GitHub
parent 4b5bd750e8
commit 602a74591e
6 changed files with 40 additions and 32 deletions
+9 -3
View File
@@ -40,7 +40,7 @@ export async function spawnShards(
data.shards > lastShardID ? data.shards : lastShardID,
];
// Start The shard
await createShard(data, payload, false, shardID);
createShard(data, payload, false, shardID);
// Spawn next shard
await spawnShards(
data,
@@ -90,7 +90,7 @@ export async function handleDiscordPayload(
}
}
export function requestAllMembers(
export async function requestAllMembers(
guild: Guild,
resolve: (
value: Collection<string, Member> | PromiseLike<Collection<string, Member>>,
@@ -99,7 +99,13 @@ export function requestAllMembers(
) {
const nonce = `${guild.id}-${Date.now()}`;
cache.fetchAllMembersProcessingRequests.set(nonce, resolve);
return requestGuildMembers(guild.id, guild.shardID, nonce, options);
await requestGuildMembers(
guild.id,
guild.shardID,
nonce,
options,
);
}
export function sendGatewayCommand(