From f67ac1b0fd950cbd58f1c80571192c860122636d Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:28:09 +0530 Subject: [PATCH 1/6] Uncommented working code, added missing await and a check for messages from a moderator --- .../cogs/verification/verification_on_join.py | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index ee804c6..979a94b 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -81,34 +81,39 @@ async def on_member_join(self, member: discord.Member): # Is being called even though it should not be. # await self.kick_if_not_verified(member, 3600, verification_log) - # @commands.Cog.listener() - # async def on_message(self, message): - # """ - # Keep verification clean again - # """ - # if message.author.guild.id != int(os.getenv("MASTER_GUILD")): - # logger.warning("on_message in verification fired, but not in master guild. Ignoring event.") - # return - # - # if message.channel.id == int(self.verification_channel): - # if not message.author.bot: - # if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact - # # user is doing it right, and the verification_dropdown is triggered - # logger.debug(f"{message.author.name} started verification.") - # await sleep(3) - # await message.delete() # cleanup correct verification calls - # return - # else: # this covers any other message in the channel. - # await message.delete() # delete the user's incorrect message - # bot_message = await message.channel.send( - # f"You need to use the **{os.getenv('PREFIX')}verify** command.") - # - # logs_channel = await self.bot.fetch_channel(self.verification_log) - # await logs_channel.send( - # f"{message.author} is failing at life in {self.bot.get_channel(self.verification_channel)}") - # - # await sleep(8) - # bot_message.delete() # remove the message to correct people after 8? seconds + @commands.Cog.listener() + async def on_message(self, message): + """ + Keep verification clean again + """ + if message.author.guild.id != int(os.getenv("MASTER_GUILD")): + logger.warning("on_message in verification fired, but not in master guild. Ignoring event.") + return + + if message.channel.id == int(self.verification_channel): + if ( + not message.author.bot and + not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_member) + ): + if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact + # user is doing it right, and the verification_dropdown is triggered + logger.debug(f"{message.author.name} started verification.") + await sleep(3) + await message.delete() # cleanup correct verification calls + return + else: # this covers any other message in the channel. + await message.delete() # delete the user's incorrect message + bot_message = await message.channel.send( + f"You need to use the **{os.getenv('PREFIX')}verify** command." + ) + + logs_channel = await self.bot.fetch_channel(self.verification_log) + await logs_channel.send( + f"{message.author} is failing at life in {self.bot.get_channel(int(self.verification_channel)).mention}" + ) + + await sleep(8) + await bot_message.delete() # remove the message to correct people after 8? seconds async def setup(bot: commands.Bot) -> None: From 4db980ddb7e8c8f0835181e3ff15a4c98ca148bd Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:30:52 +0530 Subject: [PATCH 2/6] Fixed message deletion and comparison of string id with int ids --- src/bot/cogs/verification/verification_dropdown.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 6b5604d..5fb1c7a 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -83,7 +83,7 @@ async def callback(self, interaction: discord.Interaction): except AttributeError as no_role_set: await verification_log.send( - f"{interaction.user.display_name} is trying to verify, but there is no " + f"{interaction.user.display_name} is trying to verify, but there is no" f"verification role set!" ) logger.critical(no_role_set) @@ -91,13 +91,13 @@ async def callback(self, interaction: discord.Interaction): "Someone is verifying, but there is no verification role set!" ) else: - msg = await interaction.response.send_message("You are a robot? Nice try.") + response = await interaction.response.send_message("You are a robot? Nice try.") await verification_log.send( - f"{interaction.user.display_name} admitted to being a robot, and was kicked. " + f"{interaction.user.display_name} admitted to being a robot, and was kicked." ) sleep(3) + await response.resource.delete() await interaction.user.kick(reason="User admitted to being a robot.") - await msg.delete() class DropdownView(discord.ui.View): @@ -131,7 +131,7 @@ async def verify(self, ctx): return else: - if self.verified_role not in [role.id for role in ctx.author.roles]: + if int(self.verified_role) not in [role.id for role in ctx.author.roles]: logger.debug(f"{ctx.author.name} is attempting to verify") await ctx.send( "# ~ Verification ~ \n" @@ -141,7 +141,9 @@ async def verify(self, ctx): delete_after=15.0, ) else: - await ctx.send("You are already verified. Go away.") + msg = await ctx.send("You are already verified. Go away.") + sleep(10) + await msg.delete() async def setup(bot: commands.Bot) -> None: From 5069edcfab68efbd9b70e2955310a4ab2fd9926e Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:32:11 +0530 Subject: [PATCH 3/6] Skip logging deleted messages from verification process --- src/bot/cogs/logging/logging_message_delete.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index 73b16d8..ad27e32 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -49,6 +49,8 @@ def __init__(self, bot): self.staff_channel = self.bot.api.get_one_setting("3")[0]["setting"][ 2 ] # Staff Channel ID + self.verification_channel = self.bot.api.get_one_setting("1")[0]["setting"][2] + self.verification_command = f"{os.getenv("PREFIX")}verify" self.chat_log = self.bot.api.get_one_log_setting("3") # chat_log @commands.Cog.listener() @@ -65,10 +67,19 @@ async def on_message_delete(self, message): ) return - if message.channel.id == self.staff_channel: + if message.channel.id == int(self.staff_channel): logger.debug("Message delete in staff channel was ignored.") return + if ( + message.channel.id == int(self.verification_channel) and ( + message.author.bot or + message.content == self.verification_command + ) + ): + logger.debug("Message from verification process was ignored.") + return + audit_log = [entry async for entry in message.guild.audit_logs(limit=1)][0] if self.chat_log[0]["status"] == "ok": if self.chat_log[0]["logging"][2] == "0": From 170c84d7b1b78745a078290aa2893c2a4132366b Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:41:05 +0530 Subject: [PATCH 4/6] Fixed a typo and a bit of formatting --- src/bot/cogs/logging/logging_message_delete.py | 7 ++++--- src/bot/cogs/verification/verification_on_join.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index ad27e32..d73d7c1 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -72,9 +72,10 @@ async def on_message_delete(self, message): return if ( - message.channel.id == int(self.verification_channel) and ( - message.author.bot or - message.content == self.verification_command + message.channel.id == int(self.verification_channel) + and ( + message.author.bot + or message.content == self.verification_command ) ): logger.debug("Message from verification process was ignored.") diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index 979a94b..16ce1c4 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -92,8 +92,8 @@ async def on_message(self, message): if message.channel.id == int(self.verification_channel): if ( - not message.author.bot and - not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_member) + not message.author.bot + and not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_members) ): if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact # user is doing it right, and the verification_dropdown is triggered From 4904b5600f64313eb5c9d529135d38d806f48614 Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:58:13 +0530 Subject: [PATCH 5/6] Ruff pre-commit changes --- src/bot/cogs/logging/logging_message_delete.py | 10 +++------- src/bot/cogs/verification/verification_dropdown.py | 4 +++- src/bot/cogs/verification/verification_on_join.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index d73d7c1..52332ae 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -50,7 +50,7 @@ def __init__(self, bot): 2 ] # Staff Channel ID self.verification_channel = self.bot.api.get_one_setting("1")[0]["setting"][2] - self.verification_command = f"{os.getenv("PREFIX")}verify" + self.verification_command = f"{os.getenv('PREFIX')}verify" self.chat_log = self.bot.api.get_one_log_setting("3") # chat_log @commands.Cog.listener() @@ -71,12 +71,8 @@ async def on_message_delete(self, message): logger.debug("Message delete in staff channel was ignored.") return - if ( - message.channel.id == int(self.verification_channel) - and ( - message.author.bot - or message.content == self.verification_command - ) + if message.channel.id == int(self.verification_channel) and ( + message.author.bot or message.content == self.verification_command ): logger.debug("Message from verification process was ignored.") return diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 5fb1c7a..9318336 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -91,7 +91,9 @@ async def callback(self, interaction: discord.Interaction): "Someone is verifying, but there is no verification role set!" ) else: - response = await interaction.response.send_message("You are a robot? Nice try.") + response = await interaction.response.send_message( + "You are a robot? Nice try." + ) await verification_log.send( f"{interaction.user.display_name} admitted to being a robot, and was kicked." ) diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index 16ce1c4..e33fbc1 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -87,13 +87,15 @@ async def on_message(self, message): Keep verification clean again """ if message.author.guild.id != int(os.getenv("MASTER_GUILD")): - logger.warning("on_message in verification fired, but not in master guild. Ignoring event.") + logger.warning( + "on_message in verification fired, but not in master guild. Ignoring event." + ) return if message.channel.id == int(self.verification_channel): - if ( - not message.author.bot - and not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_members) + if not message.author.bot and not ( + message.author.guild_permissions.administrator + or message.author.guild_permissions.ban_members ): if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact # user is doing it right, and the verification_dropdown is triggered @@ -113,7 +115,9 @@ async def on_message(self, message): ) await sleep(8) - await bot_message.delete() # remove the message to correct people after 8? seconds + await ( + bot_message.delete() + ) # remove the message to correct people after 8? seconds async def setup(bot: commands.Bot) -> None: From a50522c9ea9236a61f862843f9c00f30a21a0ce8 Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 17:13:42 +0530 Subject: [PATCH 6/6] Fixed removal a necessary space thinking it was unnecessary --- src/bot/cogs/verification/verification_dropdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 9318336..2726bf7 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -83,7 +83,7 @@ async def callback(self, interaction: discord.Interaction): except AttributeError as no_role_set: await verification_log.send( - f"{interaction.user.display_name} is trying to verify, but there is no" + f"{interaction.user.display_name} is trying to verify, but there is no " f"verification role set!" ) logger.critical(no_role_set)