From d3aaf642bdf8fb8ef2d2aa91ee8596c9bb807bb2 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 20 Feb 2025 11:08:03 -0500 Subject: [PATCH] Add isinstance check for text channel. --- .vscode/settings.json | 2 +- cogs/commands/submission.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a0b6d48..0ba4286 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,6 @@ "python.analysis.diagnosticSeverityOverrides": { "reportOptionalMemberAccess": false, "reportArgumentType": "information", - "reportAttributeAccessIssue": "information" + "reportAttributeAccessIssue": "warning" } } \ No newline at end of file diff --git a/cogs/commands/submission.py b/cogs/commands/submission.py index 4aeefd8..626c391 100644 --- a/cogs/commands/submission.py +++ b/cogs/commands/submission.py @@ -9,6 +9,7 @@ from sqlalchemy.orm import Session from cogs.submission.verification_view import VerificationView from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Submission, engine +from main import logger from utilities.utils import GUILDS, autofill_categories, autofill_groups, submit_score @@ -86,6 +87,14 @@ class SubmissionCog(commands.Cog): "Registered Verification channel does not exist or was never registered. Contact server admins." ) await interaction.response.send_message(error_response, ephemeral=True) + return + + if not isinstance(channel, nextcord.TextChannel): + await interaction.response.send_message("An error happened with submission.") + logger.error( + "Channel id %s in guild %s is does not correspond to a TextChannel.", channel.id, channel.guild.id + ) + return # Send the verification message to admins verification_message = await channel.send(