fix memory leak o_o

This commit is contained in:
cirroskais 2024-03-05 23:24:39 -05:00
parent 0784d1b8ad
commit 101fd3a879
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D
3 changed files with 8 additions and 7 deletions

View file

@ -14,6 +14,7 @@ export function handle(interaction: Interaction) {
const resolved = commands.get(interaction.data.name); const resolved = commands.get(interaction.data.name);
if (!resolved) return interaction.respond("Internal Error: SLASHCOMMAND_NOT_FOUND", { isPrivate: true }); if (!resolved) return interaction.respond("Internal Error: SLASHCOMMAND_NOT_FOUND", { isPrivate: true });
resolved resolved
.run(interaction) .run(interaction)
.then((response: InteractionResponse) => .then((response: InteractionResponse) =>

View file

@ -22,9 +22,8 @@ export async function load(client: Bot) {
export function handle(interaction: Interaction) { export function handle(interaction: Interaction) {
const { type } = interaction; const { type } = interaction;
if (type == InteractionTypes.ApplicationCommand) { if (type == InteractionTypes.ApplicationCommand) CommandHandler.handle(interaction);
CommandHandler.handle(interaction); else if (type == InteractionTypes.MessageComponent) {
} else if (type == InteractionTypes.MessageComponent) {
REST.sendInteractionResponse(interaction.id, interaction.token, { REST.sendInteractionResponse(interaction.id, interaction.token, {
type: InteractionResponseTypes.ChannelMessageWithSource, type: InteractionResponseTypes.ChannelMessageWithSource,
data: { data: {
@ -39,7 +38,5 @@ export function handle(interaction: Interaction) {
choices: [{ name: "not_implemented", value: "Not Implemented" }], choices: [{ name: "not_implemented", value: "Not Implemented" }],
}, },
}); });
} else if (type == InteractionTypes.ModalSubmit) { } else if (type == InteractionTypes.ModalSubmit) ModalHandler.handle(interaction);
ModalHandler.handle(interaction);
}
} }

View file

@ -25,7 +25,10 @@ export function collectModal(modal: Modal): Promise<ModalResponse> {
modal.setId(id); modal.setId(id);
modals.set(id, resolve); modals.set(id, resolve);
setTimeout(() => reject(new Error("Modal timeout")), 1000 * 30); //, 1000 * 60 * 30); setTimeout(() => {
modals.delete(id);
reject(new Error("Modal timeout"));
}, 1000 * 60 * 30);
}); });
} }