Correct some parameter usage, handle errors if searches return nothing.
This commit is contained in:
Vendored
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
"ondelete"
|
"ondelete"
|
||||||
],
|
],
|
||||||
"python.analysis.diagnosticSeverityOverrides": {
|
"python.analysis.diagnosticSeverityOverrides": {
|
||||||
"reportOptionalMemberAccess": false,
|
"reportOptionalMemberAccess": "warning",
|
||||||
"reportArgumentType": "information",
|
"reportArgumentType": "information",
|
||||||
"reportAttributeAccessIssue": "warning"
|
"reportAttributeAccessIssue": "warning"
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-8
@@ -52,8 +52,10 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
.where(col(CategoryGroup.guild_id) == interaction.guild_id)
|
.where(col(CategoryGroup.guild_id) == interaction.guild_id)
|
||||||
.where(col(CategoryGroup.id) == int(group_id))
|
.where(col(CategoryGroup.id) == int(group_id))
|
||||||
)
|
)
|
||||||
group = session.scalar(stmt)
|
if (group := session.scalar(stmt)) is None:
|
||||||
group.ChannelId = channel_id
|
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
|
||||||
|
return
|
||||||
|
group.channel_id = channel_id
|
||||||
session.commit()
|
session.commit()
|
||||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||||
|
|
||||||
@@ -88,8 +90,11 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
.where(col(CategoryGroup.guild_id) == interaction.guild_id)
|
.where(col(CategoryGroup.guild_id) == interaction.guild_id)
|
||||||
.where(col(CategoryGroup.id) == int(group_id))
|
.where(col(CategoryGroup.id) == int(group_id))
|
||||||
)
|
)
|
||||||
group = session.scalar(stmt)
|
if (group := session.scalar(stmt)) is None:
|
||||||
group.PadLength = length
|
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
group.pad_length = length
|
||||||
session.commit()
|
session.commit()
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
f"Category pad length set to {length} for {group.name}", ephemeral=True
|
f"Category pad length set to {length} for {group.name}", ephemeral=True
|
||||||
@@ -120,7 +125,9 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(Guild).where(col(Guild.id) == interaction.guild_id)
|
stmt = select(Guild).where(col(Guild.id) == interaction.guild_id)
|
||||||
guild = session.scalar(stmt)
|
if (guild := session.scalar(stmt)) is None:
|
||||||
|
await interaction.response.send_message("Guild was not found.", ephemeral=True)
|
||||||
|
return
|
||||||
guild.submission_channel = channel_id
|
guild.submission_channel = channel_id
|
||||||
session.commit()
|
session.commit()
|
||||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||||
@@ -150,8 +157,11 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
.where(col(CategoryGroup.guild_id) == interaction.guild_id)
|
.where(col(CategoryGroup.guild_id) == interaction.guild_id)
|
||||||
.where(col(CategoryGroup.id) == int(group_id))
|
.where(col(CategoryGroup.id) == int(group_id))
|
||||||
)
|
)
|
||||||
group = session.scalar(stmt)
|
if (group := session.scalar(stmt)) is None:
|
||||||
group.UsernameLength = length
|
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
group.username_length = length
|
||||||
session.commit()
|
session.commit()
|
||||||
await interaction.response.send_message(f"Username length set to {length}.", ephemeral=True)
|
await interaction.response.send_message(f"Username length set to {length}.", ephemeral=True)
|
||||||
|
|
||||||
@@ -178,7 +188,9 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(Guild).where(col(Guild.id) == interaction.guild_id)
|
stmt = select(Guild).where(col(Guild.id) == interaction.guild_id)
|
||||||
guild = session.scalar(stmt)
|
if (guild := session.scalar(stmt)) is None:
|
||||||
|
await interaction.response.send_message("Guild was not found.", ephemeral=True)
|
||||||
|
return
|
||||||
guild.verification_channel = channel_id
|
guild.verification_channel = channel_id
|
||||||
session.commit()
|
session.commit()
|
||||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user