Make commands more robust against errors.
This commit is contained in:
+20
-21
@@ -58,15 +58,16 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
# Use the relationship to get group category is in.
|
# Use the relationship to get group category is in.
|
||||||
group = category.category_group
|
group = category.category_group
|
||||||
if group is None:
|
if group is None:
|
||||||
await interaction.response.send_message(
|
agon_logger.error(f"{category.name}:{category.id} group relationship was None.")
|
||||||
f"An error with {category.name} and group relationship. Contact developer. Size was still updated.",
|
|
||||||
ephemeral=True,
|
stmt = select(CategoryGroup).where(col(CategoryGroup.id) == group_id)
|
||||||
)
|
group = session.scalar(stmt)
|
||||||
agon_logger.error(f"{category.name}:{category.id} group relationship was None.")
|
if group is None:
|
||||||
return
|
await interaction.response.send_message("Group was not found.", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
await send_highscore_message(session, interaction.guild, group)
|
await send_highscore_message(session, interaction.guild, group)
|
||||||
await interaction.response.send_message(f"{category.name} size has been updated to {size}.", ephemeral=True)
|
await interaction.response.send_message(f"{category.name} size has been updated to {size}.", ephemeral=True)
|
||||||
@@ -105,18 +106,16 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
# Use the relationship to get group category is in.
|
# Use the relationship to get group category is in.
|
||||||
group = category.category_group
|
group = category.category_group
|
||||||
if group is None:
|
if group is None:
|
||||||
await interaction.response.send_message(
|
agon_logger.error(f"{category.name}:{category.id} group relationship was None.")
|
||||||
(
|
|
||||||
f"An error with {category.name} and group relationship. Contact developer. "
|
stmt = select(CategoryGroup).where(col(CategoryGroup.id) == group_id)
|
||||||
"Is_ascending was still updated."
|
group = session.scalar(stmt)
|
||||||
),
|
if group is None:
|
||||||
ephemeral=True,
|
await interaction.response.send_message("Group was not found.", ephemeral=True)
|
||||||
)
|
return
|
||||||
agon_logger.error(f"{category.name}:{category.id} group relationship was None.")
|
|
||||||
return
|
|
||||||
|
|
||||||
await send_highscore_message(session, interaction.guild, group)
|
await send_highscore_message(session, interaction.guild, group)
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
|
|||||||
Reference in New Issue
Block a user