diff --git a/site/docs/big-bot-guide/gateway.md b/site/docs/big-bot-guide/gateway.md index f37a626eb..a3e8693e4 100644 --- a/site/docs/big-bot-guide/gateway.md +++ b/site/docs/big-bot-guide/gateway.md @@ -238,10 +238,10 @@ try again in one second by calling the `handleQueue` function. ```ts .catch(() => { - if (data.t === "INTERACTION_CREATE") return handleInteractionQueueing(gateway, data, shardId); - // IF FAILED TRY TO QUEUE MAYBE LISTENER IS DOWN - queue.events.push({ shardId, data }); + if (data.t === "INTERACTION_CREATE") handleInteractionQueueing(gateway, data, shardId); + else queue.events.push({ shardId, data }); + setTimeout(handleQueue, 1000); }); ``` @@ -316,7 +316,10 @@ async function handleInteractionQueueing(gateway: GatewayManager, data: GatewayP } await rest.runMethod(rest, "post", endpoints.INTERACTION_ID_TOKEN(BigInt(interaction.id), interaction.token), { - type: InteractionResponseTypes.DeferredChannelMessageWithSource, + // MESSAGE COMPONENTS NEED SPECIAL DEFER + type: InteractionTypes.MessageComponent === interaction.type + ? InteractionResponseTypes.DeferredUpdateMessage + : InteractionResponseTypes.DeferredChannelMessageWithSource, }); // ADD EVENT TO QUEUE @@ -422,10 +425,10 @@ const gateway = createGatewayManager({ // THIS IS FOR DENO MEMORY LEAK .then((res) => res.text()) .catch(() => { - if (data.t === "INTERACTION_CREATE") return handleInteractionQueueing(gateway, data, shardId); - // IF FAILED TRY TO QUEUE MAYBE LISTENER IS DOWN - queue.events.push({ shardId, data }); + if (data.t === "INTERACTION_CREATE") handleInteractionQueueing(gateway, data, shardId); + else queue.events.push({ shardId, data }); + setTimeout(handleQueue, 1000); }); }, @@ -454,10 +457,9 @@ async function handleQueue() { }) .then((res) => { res.text(); + handleQueue(); }) .catch(() => { - if (data.t === "INTERACTION_CREATE") return handleInteractionQueueing(gateway, data, shardId); - // EVENT HANDLER STILL NOT ACCEPTING REQUEST. SO ADD BACK TO QUEUE queue.events.unshift(event); // RETRY IN ONE SECOND @@ -465,8 +467,9 @@ async function handleQueue() { }); } -async function handleInteractionQueueing(gateway, data: GatewayPayload, shardId: number) { +async function handleInteractionQueueing(gateway: GatewayManager, data: GatewayPayload, shardId: number) { if (data.t !== "INTERACTION_CREATE") return; + const interaction = data.d as SnakeCasedPropertiesDeep; // IF THIS INTERACTION IS NOT DEFERABLE if ([InteractionTypes.ModalSubmit, InteractionTypes.ApplicationCommandAutocomplete].includes(interaction.type)) { @@ -522,7 +525,7 @@ option was added to allow you to choose how many shards should be managed by eac When shards are spawn they are triggered by a method on gateway. ```ts -gateway.tellClusterToIdentify = async function (gateway, workerId, shardId, bucketId) { +gateway.tellWorkerToIdentify = async function (gateway, workerId, shardId, bucketId) { await gateway.identify(gateway, shardId, gateway.maxShards); }; ``` diff --git a/site/docs/nodejs/Structures/create-structure.md b/site/docs/nodejs/Structures/create-structure.md index 473e666d4..2d1ed7d3a 100644 --- a/site/docs/nodejs/Structures/create-structure.md +++ b/site/docs/nodejs/Structures/create-structure.md @@ -24,7 +24,7 @@ await client.helpers.sendMessage(data.id, { content: "hello" }); However, you probably want to use something shorter, such as the following: ```js -const Channel { +class Channel { constructor(client, data) { this.client = client; this.id = data.id;