From 36913e05b9dde08c98b7e8cf7a229d9b15a65ddc Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 4 Mar 2022 05:30:13 +0000 Subject: [PATCH] fix: interaction bug <3 giveawaybot --- site/docs/big-bot-guide/gateway.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/site/docs/big-bot-guide/gateway.md b/site/docs/big-bot-guide/gateway.md index dbcc82302..f37a626eb 100644 --- a/site/docs/big-bot-guide/gateway.md +++ b/site/docs/big-bot-guide/gateway.md @@ -238,6 +238,8 @@ 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 }); setTimeout(handleQueue, 1000); @@ -266,6 +268,10 @@ export interface GatewayQueue { async function handleQueue() { // PLACEHOLDER FUNCTION THAT WILL HANDLE PROCESSING THE QUEUE } + +async function handleInteractionQueueing(gateway: GatewayManager, data: GatewayPayload, shardId: number) { + // PLACEHOLDER FUNCTION +} ``` Alrighty, since TypeScript stopped being annoying, let's continue. Next, we should make sure to avoid fetching when the @@ -416,6 +422,8 @@ 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 }); setTimeout(handleQueue, 1000); @@ -448,6 +456,8 @@ async function handleQueue() { res.text(); }) .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 @@ -475,7 +485,10 @@ async function handleInteractionQueueing(gateway, data: GatewayPayload, shardId: } 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