From 78a937d4e9901076cf6ab21c13eb653c1d9d69b0 Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Sun, 15 Feb 2026 13:13:18 +0100 Subject: [PATCH] (v4.1.3) Fixed unintended cooldown bug with modals --- src/commands/ticket.ts | 23 +++++++++++++---------- src/core/api/modules/responder.ts | 18 ++++++++---------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/commands/ticket.ts b/src/commands/ticket.ts index 65159fb..ce26854 100644 --- a/src/commands/ticket.ts +++ b/src/commands/ticket.ts @@ -54,15 +54,15 @@ export const registerCommandResponders = async () => { instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-option-unknown").build(source,{guild:instance.guild,channel:instance.channel,user:instance.user})) return cancel() } - - //check ticket permissions - if (!(await checkTicketCreationPerms(instance,source,guild,user,option))) return cancel() - + //start ticket creation if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){ //send modal instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build(source,{guild,channel,user,option})) }else{ + //check ticket permissions + if (!(await checkTicketCreationPerms(instance,source,guild,user,option))) return cancel() + //create ticket await instance.defer(true) const res = await opendiscord.actions.get("opendiscord:create-ticket").run(source,{guild,user,answers:[],option}) @@ -106,14 +106,14 @@ export const registerButtonResponders = async () => { return cancel() } - //check ticket permissions - if (!(await checkTicketCreationPerms(instance,"panel-button",guild,user,option))) return cancel() - //start ticket creation if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){ //send modal instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build("panel-button",{guild,channel,user,option})) }else{ + //check ticket permissions + if (!(await checkTicketCreationPerms(instance,"panel-button",guild,user,option))) return cancel() + //create ticket await instance.defer((generalConfig.data.system.replyOnTicketCreation) ? "reply" : "update",true) @@ -150,14 +150,14 @@ export const registerDropdownResponders = async () => { return cancel() } - //check ticket permissions - if (!(await checkTicketCreationPerms(instance,"panel-dropdown",guild,user,option))) return cancel() - //start ticket creation if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){ //send modal instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build("panel-dropdown",{guild,channel,user,option})) }else{ + //check ticket permissions + if (!(await checkTicketCreationPerms(instance,"panel-dropdown",guild,user,option))) return cancel() + //create ticket await instance.defer((generalConfig.data.system.replyOnTicketCreation) ? "reply" : "update",true) @@ -228,6 +228,9 @@ export const registerModalResponders = async () => { } }) + //check ticket permissions + if (!(await checkTicketCreationPerms(instance,originalSource,guild,user,option))) return cancel() + //create ticket const res = await opendiscord.actions.get("opendiscord:create-ticket").run(originalSource,{guild,user,answers,option}) if (!res.channel || !res.ticket){ diff --git a/src/core/api/modules/responder.ts b/src/core/api/modules/responder.ts index 3398ab2..9f1da86 100644 --- a/src/core/api/modules/responder.ts +++ b/src/core/api/modules/responder.ts @@ -1071,15 +1071,9 @@ export class ODModalResponderInstance { async reply(msg:ODMessageBuildResult): Promise> { try{ const msgFlags: number[] = msg.ephemeral ? [discord.MessageFlags.Ephemeral] : [] - if (this.interaction.replied || this.interaction.deferred){ - const sent = await this.interaction.editReply(Object.assign(msg.message,{flags:msgFlags})) - this.didReply = true - return {success:true,message:sent} - }else{ - const sent = await this.interaction.reply(Object.assign(msg.message,{flags:msgFlags})) - this.didReply = true - return {success:true,message:await sent.fetch()} - } + const sent = await this.interaction.followUp(Object.assign(msg.message,{flags:msgFlags})) + this.didReply = true + return {success:true,message:sent} }catch{ return {success:false,message:null} } @@ -1092,7 +1086,11 @@ export class ODModalResponderInstance { const sent = await this.interaction.editReply(Object.assign(msg.message,{flags:msgFlags})) this.didReply = true return {success:true,message:await sent.fetch()} - }else throw new ODSystemError("Unable to update modal interaction!") + }else{ + const sent = await this.interaction.reply(Object.assign(msg.message,{flags:msgFlags})) + this.didReply = true + return {success:true,message:await sent.fetch()} + } }catch{ return {success:false,message:null} }