diff --git a/.vscode/settings.json b/.vscode/settings.json index 47e3829..1dc3b48 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,8 +10,8 @@ "ondelete" ], "python.analysis.diagnosticSeverityOverrides": { - "reportOptionalMemberAccess": false, + "reportOptionalMemberAccess": "warning", "reportArgumentType": "information", "reportAttributeAccessIssue": "warning" } -} +} \ No newline at end of file diff --git a/cogs/commands/set.py b/cogs/commands/set.py index f69171a..ca3b437 100644 --- a/cogs/commands/set.py +++ b/cogs/commands/set.py @@ -259,8 +259,10 @@ class SetCog(commands.Cog, name="Set command."): .where(col(CategoryGroup.guild_id) == interaction.guild_id) .where(col(CategoryGroup.id) == int(group_id)) ) - group = session.scalar(stmt) - group.ChannelId = channel_id + if (group := session.scalar(stmt)) is None: + await interaction.response.send_message("Group or Category was not found.", ephemeral=True) + return + group.channel_id = channel_id session.commit() await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True) @@ -296,7 +298,8 @@ class SetCog(commands.Cog, name="Set command."): if (group := session.scalar(stmt)) is None: await interaction.response.send_message("Group was not found.", ephemeral=True) return - group.PadLength = length + + group.pad_length = length session.commit() await interaction.response.send_message( f"Category pad length set to {length} for {group.name}", ephemeral=True @@ -328,7 +331,9 @@ class SetCog(commands.Cog, name="Set command."): with Session(engine) as session: 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 session.commit() await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True) @@ -358,8 +363,11 @@ class SetCog(commands.Cog, name="Set command."): .where(col(CategoryGroup.guild_id) == interaction.guild_id) .where(col(CategoryGroup.id) == int(group_id)) ) - group = session.scalar(stmt) - group.UsernameLength = length + if (group := session.scalar(stmt)) is None: + await interaction.response.send_message("Group or Category was not found.", ephemeral=True) + return + + group.username_length = length session.commit() await interaction.response.send_message(f"Username length set to {length}.", ephemeral=True) @@ -386,8 +394,10 @@ class SetCog(commands.Cog, name="Set command."): with Session(engine) as session: stmt = select(Guild).where(col(Guild.id) == interaction.guild_id) - guild = session.scalar(stmt) - guild.VerificationChannel = channel_id + if (guild := session.scalar(stmt)) is None: + await interaction.response.send_message("Guild was not found.", ephemeral=True) + return + guild.verification_channel = channel_id session.commit() await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True) diff --git a/utilities/utils.py b/utilities/utils.py index ecb8474..caaecc1 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -398,7 +398,7 @@ async def submit_score( existing_score = session.scalar(stmt) if existing_score: - existing_score.Score = score_f + existing_score.score = score_f else: score_obj = Score(username=username, score=score_f, category_id=category_id) session.add(score_obj)