(v4.1.3) Fixed unintended cooldown bug with modals
This commit is contained in:
+13
-10
@@ -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}))
|
instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:error-option-unknown").build(source,{guild:instance.guild,channel:instance.channel,user:instance.user}))
|
||||||
return cancel()
|
return cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
//check ticket permissions
|
|
||||||
if (!(await checkTicketCreationPerms(instance,source,guild,user,option))) return cancel()
|
|
||||||
|
|
||||||
//start ticket creation
|
//start ticket creation
|
||||||
if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){
|
if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){
|
||||||
//send modal
|
//send modal
|
||||||
instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build(source,{guild,channel,user,option}))
|
instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build(source,{guild,channel,user,option}))
|
||||||
}else{
|
}else{
|
||||||
|
//check ticket permissions
|
||||||
|
if (!(await checkTicketCreationPerms(instance,source,guild,user,option))) return cancel()
|
||||||
|
|
||||||
//create ticket
|
//create ticket
|
||||||
await instance.defer(true)
|
await instance.defer(true)
|
||||||
const res = await opendiscord.actions.get("opendiscord:create-ticket").run(source,{guild,user,answers:[],option})
|
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()
|
return cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
//check ticket permissions
|
|
||||||
if (!(await checkTicketCreationPerms(instance,"panel-button",guild,user,option))) return cancel()
|
|
||||||
|
|
||||||
//start ticket creation
|
//start ticket creation
|
||||||
if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){
|
if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){
|
||||||
//send modal
|
//send modal
|
||||||
instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build("panel-button",{guild,channel,user,option}))
|
instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build("panel-button",{guild,channel,user,option}))
|
||||||
}else{
|
}else{
|
||||||
|
//check ticket permissions
|
||||||
|
if (!(await checkTicketCreationPerms(instance,"panel-button",guild,user,option))) return cancel()
|
||||||
|
|
||||||
//create ticket
|
//create ticket
|
||||||
await instance.defer((generalConfig.data.system.replyOnTicketCreation) ? "reply" : "update",true)
|
await instance.defer((generalConfig.data.system.replyOnTicketCreation) ? "reply" : "update",true)
|
||||||
|
|
||||||
@@ -150,14 +150,14 @@ export const registerDropdownResponders = async () => {
|
|||||||
return cancel()
|
return cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
//check ticket permissions
|
|
||||||
if (!(await checkTicketCreationPerms(instance,"panel-dropdown",guild,user,option))) return cancel()
|
|
||||||
|
|
||||||
//start ticket creation
|
//start ticket creation
|
||||||
if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){
|
if (option.exists("opendiscord:questions") && option.get("opendiscord:questions").value.length > 0){
|
||||||
//send modal
|
//send modal
|
||||||
instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build("panel-dropdown",{guild,channel,user,option}))
|
instance.modal(await opendiscord.builders.modals.getSafe("opendiscord:ticket-questions").build("panel-dropdown",{guild,channel,user,option}))
|
||||||
}else{
|
}else{
|
||||||
|
//check ticket permissions
|
||||||
|
if (!(await checkTicketCreationPerms(instance,"panel-dropdown",guild,user,option))) return cancel()
|
||||||
|
|
||||||
//create ticket
|
//create ticket
|
||||||
await instance.defer((generalConfig.data.system.replyOnTicketCreation) ? "reply" : "update",true)
|
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
|
//create ticket
|
||||||
const res = await opendiscord.actions.get("opendiscord:create-ticket").run(originalSource,{guild,user,answers,option})
|
const res = await opendiscord.actions.get("opendiscord:create-ticket").run(originalSource,{guild,user,answers,option})
|
||||||
if (!res.channel || !res.ticket){
|
if (!res.channel || !res.ticket){
|
||||||
|
|||||||
@@ -1071,15 +1071,9 @@ export class ODModalResponderInstance {
|
|||||||
async reply(msg:ODMessageBuildResult): Promise<ODMessageBuildSentResult<boolean>> {
|
async reply(msg:ODMessageBuildResult): Promise<ODMessageBuildSentResult<boolean>> {
|
||||||
try{
|
try{
|
||||||
const msgFlags: number[] = msg.ephemeral ? [discord.MessageFlags.Ephemeral] : []
|
const msgFlags: number[] = msg.ephemeral ? [discord.MessageFlags.Ephemeral] : []
|
||||||
if (this.interaction.replied || this.interaction.deferred){
|
const sent = await this.interaction.followUp(Object.assign(msg.message,{flags:msgFlags}))
|
||||||
const sent = await this.interaction.editReply(Object.assign(msg.message,{flags:msgFlags}))
|
this.didReply = true
|
||||||
this.didReply = true
|
return {success:true,message:sent}
|
||||||
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()}
|
|
||||||
}
|
|
||||||
}catch{
|
}catch{
|
||||||
return {success:false,message:null}
|
return {success:false,message:null}
|
||||||
}
|
}
|
||||||
@@ -1092,7 +1086,11 @@ export class ODModalResponderInstance {
|
|||||||
const sent = await this.interaction.editReply(Object.assign(msg.message,{flags:msgFlags}))
|
const sent = await this.interaction.editReply(Object.assign(msg.message,{flags:msgFlags}))
|
||||||
this.didReply = true
|
this.didReply = true
|
||||||
return {success:true,message:await sent.fetch()}
|
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{
|
}catch{
|
||||||
return {success:false,message:null}
|
return {success:false,message:null}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user