types: better types (#413)

* Update cache.ts

* Update shard_manager.ts
This commit is contained in:
ITOH
2021-01-23 20:15:11 +01:00
committed by GitHub
parent 76e0395319
commit f70a989a21
2 changed files with 13 additions and 6 deletions
+8 -3
View File
@@ -10,9 +10,14 @@ export interface CacheData {
members: Collection<string, Member>;
unavailableGuilds: Collection<string, number>;
presences: Collection<string, PresenceUpdatePayload>;
// TODO: The type Collection's second provided generic [function] should have a definite shape.
// deno-lint-ignore ban-types
fetchAllMembersProcessingRequests: Collection<string, Function>;
fetchAllMembersProcessingRequests: Collection<
string,
(
value:
| Collection<string, Member>
| PromiseLike<Collection<string, Member>>,
) => void
>;
executedSlashCommands: Collection<string, string>;
}
+5 -3
View File
@@ -1,5 +1,6 @@
import { controllers } from "../api/controllers/mod.ts";
import { Guild } from "../api/structures/guild.ts";
import { Member } from "../api/structures/mod.ts";
import { eventHandlers, IdentifyPayload } from "../bot.ts";
import {
DiscordBotGatewayData,
@@ -8,6 +9,7 @@ import {
GatewayOpcode,
} from "../types/mod.ts";
import { cache } from "../util/cache.ts";
import { Collection } from "../util/collection.ts";
import { BotStatusRequest, delay } from "../util/utils.ts";
import {
botGatewayStatusRequest,
@@ -90,9 +92,9 @@ export async function handleDiscordPayload(
export function requestAllMembers(
guild: Guild,
// TODO: The parameter "resolve" should have a "stronger" type.
// deno-lint-ignore ban-types
resolve: Function,
resolve: (
value: Collection<string, Member> | PromiseLike<Collection<string, Member>>,
) => void,
options?: FetchMembersOptions,
) {
const nonce = `${guild.id}-${Date.now()}`;