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.')```