#modal

1 messages · Page 1 of 1 (latest)

tawny ginkgo
#

how to handle if the user open the modal but don’t valid and close ?

ModalContext = await ctx.bot.wait_for_modal(my_modal)

balmy falconBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

snow sapphire
#

there is no way

tawny ginkgo
snow sapphire
#

you can add a timeout to the wait_for function yes

tawny ginkgo
snow sapphire
#

what button?

tawny ginkgo
# snow sapphire what button?

The button « mon montage » opens a modal but if the user leaves the modal without entering any information when they click on my montage again, there's an "interaction error".

snow sapphire
#

can you show the entire error

tawny ginkgo
snow sapphire
#

probably the way you structured your code

#

can you send the code where you use wait_for_modal

tawny ginkgo
# snow sapphire can you send the code where you use wait_for_modal
        mon_montage = Modal(
            ShortText(
                label="Début du clip",
                custom_id="clip_start",
                value="00:00:00",
            ),
            ShortText(
                label="Fin du clip",
                custom_id="clip_end",
                value="00:02:00",
            ),
            title="Mon Montage (Max 2min)",
        )
        await used_component.ctx.send_modal(modal=mon_montage)
        montage_ctx = await ctx.bot.wait_for_modal(mon_montage)
        statut = await montage_ctx.send("⌛️ En cours de traitement...")
        start_time = convertir_en_secondes(
            montage_ctx.responses["clip_start"])
        duration = convertir_en_secondes(
            montage_ctx.responses["clip_end"]) - start_time
        if duration > 3 * 60:
            await montage_ctx.send("Durée max : 3 min. ⏳⚠️ Respecte la limite !")
            deleteCreditEnCours(str(ctx.user.id))
            return
snow sapphire
#

the problem here is that your modal callback is local

#

i.e. if you go out of this function you have no way to reference it

#

ok I think I know

#

I guess that your button you also use wait_for_component?

#

So the issue is that your code is never executed again if you don't run /generate