#Modal Error on Submitting

1 messages · Page 1 of 1 (latest)

abstract sky
#

I have a modal, that when the submit button is pressed, function until the last line, where it gives the "Something went wrong" error at the top and does not close the modal.

    async def callback(self, interaction: discord.Interaction):
        async_session = sessionmaker(self.engine, expire_on_commit=False, class_=AsyncSession)
        async with async_session() as session:
            result = await session.execute(select(Global).where(
                or_(
                    Global.tracker_channel == self.ctx.interaction.channel_id,
                    Global.gm_tracker_channel == self.ctx.interaction.channel_id
                )
            )
            )
            guild = result.scalars().one()

        embed = discord.Embed(
            title="Character Updated (PF2)",
            fields=[
                discord.EmbedField(
                    name="Name: ", value=self.name, inline=True
                ),
                discord.EmbedField(
                    name="AC: ", value=self.children[0].value, inline=True
                ),
                discord.EmbedField(
                    name="Fort: ", value=self.children[1].value, inline=True
                ),
                discord.EmbedField(
                    name="Reflex: ", value=self.children[2].value, inline=True
                ),
                discord.EmbedField(
                    name="Will: ", value=self.children[3].value, inline=True
                ),
                discord.EmbedField(
                    name="Class/Spell DC: ", value=self.children[4].value, inline=True
                ),
            ],
            color=discord.Color.dark_gold(),
        )

        async_session = sessionmaker(self.engine, expire_on_commit=False, class_=AsyncSession)
        Tracker = await get_tracker(self.ctx, self.engine, id=guild.id)

        Condition = await get_condition(self.ctx, self.engine, id=guild.id)
        async with async_session() as session:
            char_result = await session.execute(select(Tracker).where(Tracker.name == self.name))
            character = char_result.scalars().one()

        for item in self.children:

            async with async_session() as session:
                result = await session.execute(select(Condition)
                                               .where(Condition.character_id==character.id)
                                               .where(Condition.title == item.label))
                condition = result.scalars().one()
                condition.number = int(item.value)
                await session.commit()

        await initiative.update_pinned_tracker(self.ctx, self.engine, self.bot)
        print('Tracker Updated')
        await self.ctx.channel.send(embeds=[embed])
        await interaction.response.send_message('Updated.')```
#

Is the callback, and the error traceback is:

Traceback (most recent call last):
  File "C:\Users\schne\PycharmProjects\discordSlashBot\venv\lib\site-packages\discord\ui\modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "C:\Users\schne\PycharmProjects\discordSlashBot\PF2e\pf2_functions.py", line 510, in callback
    await interaction.response.send_message('Updated.')
  File "C:\Users\schne\PycharmProjects\discordSlashBot\venv\lib\site-packages\discord\interactions.py", line 825, in send_message
    await self._locked_response(
  File "C:\Users\schne\PycharmProjects\discordSlashBot\venv\lib\site-packages\discord\interactions.py", line 1090, in _locked_response
    await coro
  File "C:\Users\schne\PycharmProjects\discordSlashBot\venv\lib\site-packages\discord\webhook\async_.py", line 215, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```

As far as I can tell this is the same as my other modals, as well as the example code on the github.  Anyone able to help?
thick ivy
#

It likely meant it took too long for you to respond.

abstract sky
civic oak
#

If that doesn’t work, your code is taking too long.