types: add gateway opcodes enum (#711)

* bring opcodes enum back

* Update src/types/gateway/opcodes.ts

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

* DiscordGatewayOpcodes

Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
ITOH
2021-03-29 18:58:33 +02:00
committed by GitHub
parent 367a7975f8
commit 2914874d19
5 changed files with 29 additions and 11 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ import { eventHandlers } from "../bot.ts";
import { cache } from "../cache.ts";
import { handlers } from "../handlers/mod.ts";
import { Member } from "../structures/mod.ts";
import { DiscordGatewayOpcodes } from "../types/mod.ts";
import { Collection } from "../util/collection.ts";
import { delay } from "../util/utils.ts";
import { createShard, requestGuildMembers } from "./mod.ts";
@@ -67,10 +68,10 @@ export async function handleDiscordPayload(
await eventHandlers.dispatchRequirements?.(data, shardID);
switch (data.op) {
case GatewayOpcode.HeartbeatACK:
case DiscordGatewayOpcodes.HeartbeatACK:
// In case the user wants to listen to heartbeat responses
return eventHandlers.heartbeat?.();
case GatewayOpcode.Dispatch:
case DiscordGatewayOpcodes.Dispatch:
if (!data.t) return;
// Run the appropriate handler for this event.
return handlers[data.t]?.(data, shardID);