Better debug type

This commit is contained in:
ayntee
2020-12-26 20:23:57 +04:00
parent b650ca3d8e
commit 69099e04fc
2 changed files with 15 additions and 15 deletions

View File

@@ -48,7 +48,7 @@ export interface OldMessage {
export interface DebugArg {
/** Red is for errors or urgent issues. Yellow is for warnings/alerts. Green is for actions being taken. Blue is for */
type?:
| "identifying"
| "gatewayIdentify"
| "error"
| "requestManager"
| "globallyRateLimited"
@@ -56,13 +56,13 @@ export interface DebugArg {
| "requestManagerFetching"
| "requestManagerFetched"
| "requestMembersProcessing"
| "heartbeat"
| "heartbeatStopped"
| "createShard"
| "invalidSession"
| "reconnect"
| "resuming"
| "resumed"
| "gatewayHeartbeat"
| "gatewayHeartbeatStopped"
| "shardCreate"
| "gatewayInvalidSession"
| "gatewayReconnect"
| "gatewayResume"
| "gatewayResumed"
| "wsClose"
| "wsError"
| "wsReconnect"

View File

@@ -103,14 +103,14 @@ export async function createShard(
break;
case GatewayOpcode.Reconnect:
eventHandlers.debug?.(
{ type: "reconnect", data: { shardID: basicShard.id } },
{ type: "gatewayReconnect", data: { shardID: basicShard.id } },
);
basicShard.needToResume = true;
resumeConnection(data, identifyPayload, basicShard.id);
break;
case GatewayOpcode.InvalidSession:
eventHandlers.debug?.(
{ type: "invalidSession", data: { shardID: basicShard.id, data } },
{ type: "gatewayInvalidSession", data: { shardID: basicShard.id, data } },
);
// When d is false we need to reidentify
if (!data.d) {
@@ -123,7 +123,7 @@ export async function createShard(
default:
if (data.t === "RESUMED") {
eventHandlers.debug?.(
{ type: "resumed", data: { shardID: basicShard.id } },
{ type: "gatewayResumed", data: { shardID: basicShard.id } },
);
basicShard.needToResume = false;
@@ -207,7 +207,7 @@ export async function createShard(
function identify(shard: BasicShard, payload: IdentifyPayload) {
eventHandlers.debug?.(
{
type: "identifying",
type: "gatewayIdentify",
data: {
shardID: shard.id,
},
@@ -255,7 +255,7 @@ async function heartbeat(
if (!receivedACK) {
eventHandlers.debug?.(
{
type: "heartbeatStopped",
type: "gatewayHeartbeatStopped",
data: {
interval,
previousSequenceNumber: shard.previousSequenceNumber,
@@ -277,7 +277,7 @@ async function heartbeat(
);
eventHandlers.debug?.(
{
type: "heartbeat",
type: "gatewayHeartbeat",
data: {
interval,
previousSequenceNumber: shard.previousSequenceNumber,
@@ -304,7 +304,7 @@ async function resumeConnection(
if (!shard.needToResume) return;
eventHandlers.debug?.({ type: "resuming", data: { shardID: shard.id } });
eventHandlers.debug?.({ type: "gatewayResume", data: { shardID: shard.id } });
// Run it once
createShard(data, payload, true, shard.id);
// Then retry every 15 seconds