fix: interaction bug <3 giveawaybot

This commit is contained in:
Skillz4Killz
2022-03-04 05:30:13 +00:00
committed by GitHub
parent b514b7712e
commit 36913e05b9
+14 -1
View File
@@ -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