mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
fix: sendInteractionResponse
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user