diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index 4e52fc171..04b8099a2 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -14,17 +14,6 @@ import { snakelize, validateComponents } from "../../util/utils.ts"; export async function sendInteractionResponse(id: bigint, token: string, options: DiscordenoInteractionResponse) { // TODO: add more options validations if (options.data?.components) validateComponents(options.data?.components); - // If its already been executed, we need to send a followup response - if (cache.executedSlashCommands.has(token)) { - return await rest.runMethod("post", endpoints.WEBHOOK(applicationId, token), snakelize(options)); - } - - // Expire in 15 minutes - cache.executedSlashCommands.add(token); - setTimeout(() => { - eventHandlers.debug?.("loop", `Running setTimeout in send_interaction_response file.`); - cache.executedSlashCommands.delete(token); - }, 900000); // If the user wants this as a private message mark it ephemeral if (options.private) { @@ -36,5 +25,17 @@ export async function sendInteractionResponse(id: bigint, token: string, options options.data = { ...options.data, allowedMentions: { parse: [] } }; } + // If its already been executed, we need to send a followup response + if (cache.executedSlashCommands.has(token)) { + return await rest.runMethod("post", endpoints.WEBHOOK(applicationId, token), snakelize(options.data)); + } + + // Expire in 15 minutes + cache.executedSlashCommands.add(token); + setTimeout(() => { + eventHandlers.debug?.("loop", `Running setTimeout in send_interaction_response file.`); + cache.executedSlashCommands.delete(token); + }, 900000); + return await rest.runMethod("post", endpoints.INTERACTION_ID_TOKEN(id, token), snakelize(options)); }